Updating key objects after removing data from the analysis

drug_effect_metadata_all_lines <- drug_effect_metadata
#drug_effect_metadata <- drug_effect_metadata %>% filter(!Line %in% c("D021T01", "D054T01", "D055T01"))

Introduction

Drug effects are defined as the vector pointing from negative control (DMSO) organoids to treated organoids in feature space. Features are transformed with a PCA and the top 25 components are retained. An SVM with a linear kernel is trained to differentiate DMSO and treated organoids (for each drug individually) and the normal vector to the separating hyperplane is defined as the drug effect vector. It is scaled to be as long as the distance between the DMSO median and the treated organoid median in feature space.

The paper’s “story flow” began with the drug-induced phenotypes and then continued onto the organoid viability. However, there are interesting parallels between the two analyses so that I include the lethality of drugs in the annotation of heatmaps here.

Define Active Drugs

A histogram of the accuracies (or AUCs to be exact) shows that there are two groups of drugs. The first, normally distributed, group with low AUCs represents the inactive drugs that cannot be sufficiently differentiated from DMSO while the other group represents the active drugs that have significantly different characteristic features than the DMSO organoids and can be separated by a linear SVM hyperplane in feature space.

ggplot(data = drug_effect_metadata, mapping = aes(x = AUC_Mean)) + 
  geom_histogram(bins = 100) + 
  theme_vignette() + ggtitle("AUROC Histogram") + 
  xlab("Mean AUROC (10-fold Cross Validation)") + ylab("") + 
if(save_images) ggsave(
  filename = file.path(img_out_dir, "Histogram_ClassifierAUCs.pdf"), 
  width = 3, height = 3, useDingbats = FALSE)

The distance in feature space between drugs and DMSO clouds correlates, as expected, with the AUROC.

ggplot(data = drug_effect_metadata, 
       mapping = aes(x = AUC_Mean, y = Distance)) + 
  geom_point(size = 0.5) + 
  theme_vignette() + labs(
    caption = paste("Spearman rho =", round(
      cor(drug_effect_metadata$AUC_Mean, 
          drug_effect_metadata$Distance, method = "spearman"), 2))) + 
  xlab("AUROC") + labs(color = "")

if(save_images) ggsave(
  filename = file.path(img_out_dir, "Scatterplot_AUCvsDistance.pdf"), 
  width = 3, height = 3, useDingbats = FALSE)

The SVM was trained with 10-fold cross validation and the resulting means and standard devations of the accuracies are shown below.

ggplot(data = drug_effect_metadata, 
       mapping = aes(x = AUC_Mean, y = AUC_Std)) + 
  geom_point(size = 0.5) + theme_vignette() + 
  labs(x = "AUROC Mean", y = "AUROC Standard Deviation", color = "")

if(save_images) ggsave(
  filename = file.path(img_out_dir, "Scatterplot_AUCMeanvsAUCStd.pdf"), 
  width = 3, height = 3, useDingbats = FALSE)

Based on the bimodal histogram of active drugs, I define any drug that can be separated with \(AUC = 0.85\) from the DMSO controls as “active”.

auc_thresh = 0.85
profiles_active = drug_effect_metadata_all_lines[drug_effect_metadata_all_lines$AUC_Mean >= auc_thresh, ]
metadata_active = drug_effect_metadata_all_lines[drug_effect_metadata_all_lines$AUC_Mean >= auc_thresh, ]

The number of active drugs varies per line.

ggplot_df = as.data.frame(table(metadata_active$Line))
# D054T01 was only imaged with the small library
ggplot_df = ggplot_df[ggplot_df$Var1 != "D054T01", ]

# filtering additional lines 
ggplot_df <- ggplot_df %>% 
  dplyr::filter(!Var1 %in% c("D021T01", "D055T01"))

ggplot_df$TextLoc = ggplot_df$Freq - 50
ggplot(data = ggplot_df, mapping = aes(x = Var1, y = Freq)) + 
  geom_col() + 
  geom_text(mapping = aes(x = Var1, y = TextLoc, label = Freq), 
            color = "white", fontface = "bold", size = 3) + 
  theme_vignette() + 
  theme(axis.line = element_blank(), axis.text.x = element_blank(), 
        axis.ticks = element_blank()) + 
  xlab("") + ylab("") + ggtitle("Number of Active Drugs") + 
  coord_flip()

if(save_images) ggsave(
  filename = file.path(img_out_dir, "Barplot_NumActiveDrugs.pdf"),
  width = 2.5, height = 3)

Some drugs are active in all cell lines and others only in very few.

activity_table = table(metadata_active$Drug, metadata_active$Line)
activity_table = activity_table[, colnames(activity_table) != "D054T01"]
ggplot_df = as.data.frame(sort(rowSums(activity_table > 0), decreasing = TRUE))

colnames(ggplot_df) = "Freq"
ggplot_df$Var1 = factor(rownames(ggplot_df), levels = rownames(ggplot_df))
ggplot(data = ggplot_df, mapping = aes(x = Var1, y = Freq)) + 
  geom_col(width = 1) + theme_vignette() + theme(
    axis.text.x = element_blank(), axis.ticks.x = element_blank()) + 
  xlab("Drugs") + ylab("Number of Lines") + 
  ggtitle("Number of Lines in which a Drug is Active") + 
  scale_y_continuous(breaks = seq_len(length(lines)))

A comparison of the viability versus the drug effect shows that all drugs previously identified as lethal are also identified as active. However, a good number of active drugs were previously identified as nonlethal.

ggplot(mapping = aes(y = Viability, x = AUC_Mean)) + 
  geom_point(data = drug_effect_metadata, color = "lightgrey", size = 0.5) + 
  geom_point(data = drug_effect_metadata[
    drug_effect_metadata$AUC_Mean >= auc_thresh, ], 
             size = 0.5) + 
  theme_vignette() + ylab("Viability") + xlab("AUROC Mean") + 
  geom_segment(mapping = aes(
      y = 0, yend = 1, x = auc_thresh, xend = auc_thresh), 
    color = "red", size = 1) + coord_equal(ratio = 0.5)

if(save_images) ggsave(
  filename = file.path(img_out_dir, "Scatterplot_ViabilityVsSVMAUROC.pdf"), 
  width = 3, height = 3, useDingbats = FALSE)

Plotting a histogram of the viabilities of all “active” drugs, i.e. with \(AUROC \geq 0.85\)

ggplot(data = drug_effect_metadata[
  drug_effect_metadata$AUC_Mean >= auc_thresh, ]) + 
  geom_histogram(mapping = aes(x = Viability), bins = 25) + 
  theme_vignette()

KiStem library

I analyze the two libraries separately and begin with the KiStem library.

sel_indices = (is.na(drug_effect_metadata_all_lines$Concentration) | (
  drug_effect_metadata_all_lines$Drug %in% c("Bortezomib", "Irinotecan / SN-38") &
  drug_effect_metadata_all_lines$Concentration %in% c(0.2, 1))) & 
  # D054 was only treated with the CCP library
  drug_effect_metadata_all_lines$Line != "D054T01"
profiles = drug_effect_profiles[sel_indices, ]
metadata = drug_effect_metadata_all_lines[sel_indices, ]
sel_indices = metadata$AUC_Mean >= auc_thresh
profiles_active = profiles[sel_indices, ]
metadata_active = metadata[sel_indices, ]

Individual Cell Lines

I look at the angles between vectors. The SVM generates a profile for all drugs, including inactive ones. However, because they cannot be properly separated from DMSO, the profiles of these drugs will be largely random, ergo I remove them as noise.

killing_anno = rep(NA, nrow(metadata_active))
killing_anno[metadata_active$Viability <= 0.2] = "0.2"
killing_anno[
  metadata_active$Viability > 0.2 & 
  metadata_active$Viability <= 0.4] = "0.4"
killing_anno[
  metadata_active$Viability > 0.4 & 
  metadata_active$Viability <= 0.6] = "0.6"
killing_anno[
  metadata_active$Viability > 0.6 & 
  metadata_active$Viability <= 0.8] = "0.8"
killing_anno[
  metadata_active$Viability > 0.8 & 
  metadata_active$Viability <= 1] = "1"

annotation = data.frame(
  "Viability" = killing_anno,
  "Pathway" = SCOPEAnalysis::get_mode_of_action(metadata_active$Drug),
  "Target" = SCOPEAnalysis::get_targets(metadata_active$Drug),
  "Line" = metadata_active$Line,
  row.names = rownames(profiles_active), # needs commenting when filtering
  stringsAsFactors = FALSE)

# Fix for slashes in targets
annotation$Target = gsub(
  pattern = "/", replacement = ", ", annotation$Target)

# Calculate the angles for each line
line_results = list()
enriched_drugs = list()
oddsratio_pathway = list()
oddsratio_target = list()
for(line in unique(substr(rownames(annotation), 1, 7))) {
  line_sel_indices = annotation$Line == line
  line_annotation = annotation[line_sel_indices, ]
  line_annotation$Line = NULL
  line_profiles = profiles_active[line_sel_indices, ]
  line_metadata = metadata_active[line_sel_indices, ]
  
  # Calc angles and cluster
  angles = get_angles(line_profiles)
  if(nrow(angles) < 2) next
  d = acos(angles)*180/pi
  hc = hclust(as.dist(d), method = "ward.D2")
  
  # Also cluster the principal components by correlation just for kicks
  cor_pca = cor(line_profiles)
  d_pca = as.dist((1 - cor_pca) / 2)
  hc_pca = hclust(d_pca, method = "ward.D2")
  
  # Annotate Pathway and Targets
  pathways = list()
  for(pathway in unique(line_annotation$Pathway)) {
    pathways[[pathway]] = grep(
      pattern = paste0("\\b", pathway, "\\b"), 
      x = line_annotation$Pathway, 
      ignore.case = TRUE)
  }
  # My cluster_enrichment function doesn't play well with NA values yet
  pathways = pathways[!is.na(names(pathways))]
  pathways_sig_vec = get_cluster_enrichment(
    clustering = hc, labels = pathways, min_cluster_size = min_cluster_size, 
    max_annotated_labels = 7)
  # 'Others' is too vague
  pathways_sig_vec$Labels[pathways_sig_vec$Labels == "Others"] = NA
  
  targets_split = tolower(line_annotation$Target)
  targets = list()
  for(target in unique(unlist(strsplit(targets_split, ", ")))) {
    targets[[target]] = grep(
      pattern = paste0("\\b", target, "\\b"), 
      x = targets_split, ignore.case = TRUE)
  }
  # My cluster_enrichment function doesn't play well with NA values yet
  targets = targets[!is.na(names(targets))]
  targets_sig_vec = get_cluster_enrichment(
    clustering = hc, labels = targets, min_cluster_size = min_cluster_size, 
    max_annotated_labels = 7)
  
  line_annotation$Pathway = pathways_sig_vec$Labels
  line_annotation$Target = targets_sig_vec$Labels

  enriched_drugs[[line]] = data.frame(
    "Drug" = substr(rownames(line_annotation), 9, 100000L), 
    "Line" = line,
    "Pathway" = annotation[annotation$Line == line, "Pathway"], 
    "Target" = annotation[annotation$Line == line, "Target"],
    "Enriched.Target" = line_annotation$Target,
    "is.pathway.enriched" = !is.na(line_annotation$Pathway), 
    "is.target.enriched" = !is.na(line_annotation$Target),
    stringsAsFactors = FALSE)
  
  if(nrow(pathways_sig_vec$Fisher.Test) > 0) {
    oddsratio_pathway[[line]] = cbind.data.frame(
      "Line" = line, pathways_sig_vec$Fisher.Test)
  }
  if(nrow(targets_sig_vec$Fisher.Test) > 0) {
    oddsratio_target[[line]] = cbind.data.frame(
      "Line" = line, targets_sig_vec$Fisher.Test)
  }
  
  line_results[[line]] = list(
    "Annotation" = line_annotation, 
    "Distances" = d, 
    "Clustering" = hc, 
    "PCAClustering" = hc_pca)
}
# Save enriched drugs
enriched_drugs = do.call(rbind, enriched_drugs)
rownames(enriched_drugs) = NULL
if(save_images) write.csv2(
  x = enriched_drugs, file = "EnrichedDrugs.csv", 
  quote = FALSE, row.names = FALSE)

# Save oddsratio Ratios
oddsratio_pathway = do.call(rbind, oddsratio_pathway)
rownames(oddsratio_pathway) = NULL
if(save_images) write.csv2(
  x = oddsratio_pathway, file = "OddsRatio_Pathways.csv", 
  quote = FALSE, row.names = FALSE)
oddsratio_target = do.call(rbind, oddsratio_target)
rownames(oddsratio_target) = NULL
if(save_images) write.csv2(
  x = oddsratio_target, file = "OddsRatio_Target.csv", 
  quote = FALSE, row.names = FALSE)
anno_colorScale = list(
  "Viability" = setNames(
    object = grDevices::colorRampPalette(c("black", "white"))(
      length(unique(annotation$Viability))), 
    nm = sort(unique(annotation$Viability))))

# Plot all results
for(line in names(line_results)) {
  line_annotation = line_results[[line]]$Annotation
  line_profiles = profiles_active[annotation$Line == line,]
  line_color = anno_colorScale
  if(sum(!is.na(line_annotation$Pathway)) == 0) line_annotation$Pathway = NULL
  if(sum(!is.na(line_annotation$Target)) == 0) line_annotation$Target = NULL
  for(column in colnames(line_annotation)) {
    if(column %in% names(line_color)) next
    entries = na.omit(unique(line_annotation[[column]]))
    line_color[[column]] = setNames(
      object = unname(colorScale)[seq_along(entries)], 
      nm = entries)
  }
  d = line_results[[line]]$Distances
  hc = line_results[[line]]$Clustering
  hc_pca = line_results[[line]]$PCAClustering
  
  # Heatmap of PCA components
  lp = line_profiles
  lp[lp > 0] = sqrt(lp[lp > 0])
  lp[lp < 0] = -sqrt(-lp[lp < 0])
  
  hm_range_limit = max(abs(lp))
  hm_breaks = seq(-hm_range_limit, hm_range_limit, length.out = 100)
  hm_legend_breaks = c(-floor(hm_range_limit), 0, floor(hm_range_limit))
  hm_legend_labels = hm_legend_breaks**2
  hm_legend_labels[hm_legend_breaks < 0] = -hm_legend_labels[hm_legend_breaks < 0]
  hm_colorscale = grDevices::colorRampPalette(
    c("#0082c8", "white", "#e6194b"))(length(hm_breaks))
  pheatmap(
      t(lp), annotation_col = line_annotation,
      color = hm_colorscale, breaks = hm_breaks,
      legend_breaks = hm_legend_breaks, legend_labels = hm_legend_labels,
      annotation_colors = line_color, show_rownames = TRUE,
      show_colnames = FALSE, cluster_rows = hc_pca, cluster_cols = hc,
      main = sprintf("Angles Between Profile Vectors for %s", line),
      border_color = NA, cellheight = 7, cellwidth = 2)
  if(save_images) pheatmap(
      t(lp), annotation_col = line_annotation, 
      color = hm_colorscale, breaks = hm_breaks,
      legend_breaks = hm_legend_breaks, legend_labels = hm_legend_labels,
      annotation_colors = line_color, show_rownames = TRUE, 
      show_colnames = FALSE, cluster_rows = hc_pca, cluster_cols = hc, 
      main = sprintf("Angles Between Profile Vectors for %s", line), 
      border_color = NA, cellheight = 7, cellwidth = 2, height = 10,
      filename = file.path(img_out_dir, sprintf("EffectVectorHeatmap_PCA_%s.pdf", line)))
  
  # Symmetrical Heatmap (save as regular image and as super large image with rownames)
  hm_colorscale = grDevices::colorRampPalette(
    rev(c("#f7f7f7", "#f7f7f7", "#f7f7f7", 
          "#E0F3F8", "#91BFDB", "#4575B4")))(150)
  pheatmap(
      d, annotation_col = line_annotation,
      color = hm_colorscale, annotation_colors = line_color, 
      show_rownames = FALSE, show_colnames = FALSE, 
      cluster_rows = hc, cluster_cols = hc,
      main = sprintf("Angles Between Profile Vectors for %s", line),
      border_color = NA, cellheight = 1.25, cellwidth = 1.25)
  if(save_images) pheatmap(
      d, annotation_col = line_annotation,
      color = hm_colorscale, annotation_colors = line_color, 
      show_rownames = TRUE, show_colnames = FALSE, 
      cluster_rows = hc, cluster_cols = hc,
      main = sprintf("Angles Between Profile Vectors for %s", line),
      # border_color = NA, cellheight = 1.25, cellwidth = 1.25, height = 10,
      border_color = NA, cellheight = 8, cellwidth = 8, 
      filename = file.path(img_out_dir, sprintf("EffectVectorHeatmap_superlarge_%s.pdf", line)))
  if(save_images) pheatmap(
      d, annotation_col = line_annotation,
      color = hm_colorscale, annotation_colors = line_color, 
      show_rownames = FALSE, show_colnames = FALSE, 
      cluster_rows = hc, cluster_cols = hc,
      main = sprintf("Angles Between Profile Vectors for %s", line),
      border_color = NA, cellheight = 1.25, cellwidth = 1.25, height = 10,
      filename = file.path(img_out_dir, sprintf("EffectVectorHeatmap_%s.pdf", line)))
  
  # Force-directed graph of active drugs
  # Set up adjacency matrix
  adjmatrix = d
  adjmatrix[adjmatrix > 45] = 0
  
  # Resort matrix to make sure annotated nodes are above unannotated ones
  sort_order = order(line_annotation$Target, na.last = FALSE)
  adjmatrix = adjmatrix[sort_order, sort_order]
  
  # Remove drugs without any connections
  sel_indices = colSums(adjmatrix != 0) != 0
  adjmatrix = adjmatrix[sel_indices, sel_indices]
  
  # Generate network
  adjmatrix = Matrix::Matrix(data = adjmatrix, sparse = TRUE)
  net = graph_from_adjacency_matrix(
    adjmatrix = adjmatrix, mode = "undirected", diag = FALSE, weighted = TRUE)
  
  # Assign targets and colors
  V(net)$target = line_annotation[match(
    V(net)$name, rownames(line_annotation)), "Target"]
  V(net)$color = V(net)$target
  for(target in na.omit(unique(V(net)$target))) {
    regex = paste0("\\b", target, "\\b")
    V(net)$color = gsub(regex, line_color$Target[target], V(net)$color)}
  V(net)$color[is.na(V(net)$color)] = "white"
  
  # Assign size
  V(net)$size = 5
  V(net)[!is.na(V(net)$target)]$size = 7.5
  
  # # Create plot
  # e = get.edgelist(net, names = FALSE)
  # l = qgraph.layout.fruchtermanreingold(
  #   edgelist = e, vcount = vcount(net), 
  #   area=20*(vcount(net)^2), repulse.rad=(vcount(net)^3.1))
  # # l = layout_with_graphopt(graph = net, niter = 1000, mass = 100)
  # plot.igraph(net, vertex.label = NA, layout=l, 
  #             edge.width = 0.5, edge.color = "lightgray", 
  #             main = line)
  # if(save_images) {
  #   pdf(file = file.path(img_out_dir, sprintf("EffectVectorNetwork_%s.pdf", line)), 
  #       width = 7, height = 7, useDingbats = FALSE)
  #   plot.igraph(net, vertex.label = NA, layout=l, 
  #               edge.width = 0.5, edge.color = "lightgray", 
  #               main = line)
  #   dev.off()}

  # # t-SNE of full profiles
  # line_profiles_full = profiles[metadata$Line == line, ]
  # tsne = Rtsne(X = line_profiles_full, perplexity = 50, max_iter = 1000)
  # tsnedf = data.frame(
  #   "X" = tsne$Y[,1],
  #   "Y" = tsne$Y[,2],
  #   "isActive" = rownames(line_profiles_full) %in% rownames(line_profiles),
  #   "Viability" = line_annotation[rownames(line_profiles_full), "Viability"],
  #   "Pathway" = line_annotation[rownames(line_profiles_full), "Pathway"],
  #   "Target" = line_annotation[rownames(line_profiles_full), "Target"],
  #   row.names = rownames(line_profiles_full)
  # )
  # ggplot() + 
  #   # Inactive drugs
  #   geom_point(data = tsnedf[!tsnedf$isActive, ], 
  #              mapping = aes(x = X, y = Y),
  #              color = "lightgray") + 
  #   # Active Drugs
  #   geom_point(data = tsnedf[tsnedf$isActive, ],
  #              mapping = aes(x = X, y = Y)) + 
  #   scale_color_manual(values = line_color$Target) + 
  #   # Enriched Drugs (Target)
  #   geom_point(data = tsnedf[!is.na(tsnedf$Target), ], 
  #              mapping = aes(
  #                x = X, y = Y, 
  #                color = tsnedf[!is.na(tsnedf$Target), "Target"])) + 
  #   theme_vignette() + ggtitle(paste0("t-SNE of all drugs ", line)) + 
  #   labs(color = "Target")
  # if(save_images) ggsave(
  #   filename = file.path(img_out_dir, sprintf(
  #     "EffectVector_allDrugs_tSNE_%s.pdf", line)), 
  #   width = 8, height = 8, useDingbats = FALSE)
  # 
  # # t-SNE of active drugs
  # tsne = Rtsne(X = line_profiles, perplexity = 20, max_iter = 1000)
  # tsnedf = data.frame(
  #   "X" = tsne$Y[,1],
  #   "Y" = tsne$Y[,2],
  #   "Viability" = line_annotation[rownames(line_profiles), "Viability"],
  #   "Pathway" = line_annotation[rownames(line_profiles), "Pathway"],
  #   "Target" = line_annotation[rownames(line_profiles), "Target"],
  #   row.names = rownames(line_profiles)
  # )
  # ggplot() +
  #   geom_point(data = tsnedf, mapping = aes(x = X, y = Y)) + 
  #   scale_color_manual(values = line_color$Target) + 
  #   # Enriched Drugs (Target)
  #   geom_point(data = tsnedf[!is.na(tsnedf$Target), ], 
  #              mapping = aes(
  #                x = X, y = Y, 
  #                color = tsnedf[!is.na(tsnedf$Target), "Target"])) + 
  #   theme_vignette() + ggtitle(paste0("t-SNE of active drugs ", line)) + 
  #   labs(color = "Target")
  # if(save_images) ggsave(
  #   filename = file.path(img_out_dir, sprintf(
  #     "EffectVector_activeDrugs_tSNE_%s.pdf", line)), 
  #   width = 8, height = 8, useDingbats = FALSE)
}

Closer Look at D004T01

D004T01 has a notable non-lethal cluster associated with mTOR

line = "D004T01"
line_annotation = line_results[[line]]$Annotation
line_profiles = profiles_active[annotation$Line == line,]
line_color = anno_colorScale
if(sum(!is.na(line_annotation$Pathway)) == 0) line_annotation$Pathway = NULL
if(sum(!is.na(line_annotation$Target)) == 0) line_annotation$Target = NULL
for(column in colnames(line_annotation)) {
  if(column %in% names(line_color)) next
  entries = na.omit(unique(line_annotation[[column]]))
  line_color[[column]] = setNames(
    object = unname(colorScale)[seq_along(entries)], 
    nm = entries)
}
d = line_results[[line]]$Distances
hc = line_results[[line]]$Clustering
hc_pca = line_results[[line]]$PCAClustering

labels = cutree(tree = hc, k = 2)
mtor_label = unique(labels[which(line_annotation$Target == "mtor")])
if(length(mtor_label) != 1) stop(
  "Critical Error with mTOR label for D004T01")
mtor_drugs = names(which(labels == mtor_label))

mtor_annotation = annotation[mtor_drugs, ]
mtor_annotation$Target = ifelse(
  test = !is.na(line_annotation[mtor_drugs, "Target"]), 
  yes = line_annotation[mtor_drugs, "Target"], 
  no = mtor_annotation[mtor_drugs, "Target"])
mtor_annotation$Line = NULL
mtor_annoColor = anno_colorScale
if(sum(!is.na(mtor_annotation$Pathway)) == 0) mtor_annotation$Pathway = NULL
if(sum(!is.na(mtor_annotation$Target)) == 0) mtor_annotation$Target = NULL
for(column in colnames(mtor_annotation)) {
  if(column %in% names(mtor_annoColor)) next
  entries = na.omit(unique(mtor_annotation[[column]]))
  mtor_annoColor[[column]] = setNames(
    object = unname(colorScale)[seq_along(entries)], 
    nm = entries)
  }

d_mtor = d[labels == mtor_label, labels == mtor_label]
hc_mtor = hclust(as.dist(d_mtor), "ward.D2")

hm_colorscale = colorRampPalette(
    rev(c("#f7f7f7", "#E0F3F8", "#91BFDB", "#4575B4")))(150)

drugnames = substr(mtor_drugs, 9, 100)

pheatmap(
  mat = d_mtor, color = hm_colorscale, 
  annotation_col = mtor_annotation, annotation_colors = mtor_annoColor, 
  cluster_rows = hc_mtor, cluster_cols = hc_mtor, labels_col = drugnames, 
  show_rownames = FALSE, cellwidth = 10, cellheight = 10, border_color = NA, 
  height = 5)

if(save_images) pheatmap(
  mat = d_mtor, color = hm_colorscale, 
  annotation_col = mtor_annotation, annotation_colors = mtor_annoColor, 
  cluster_rows = hc_mtor, cluster_cols = hc_mtor, labels_col = drugnames, 
  show_rownames = FALSE, cellwidth = 10, cellheight = 10, border_color = NA, 
  height = 10, filename = file.path(img_out_dir, sprintf(
    "EffectVectorHeatmap_Detailed_%s.pdf", line)))

Enrichment Heatmap

I look at enrichment heatmaps, i.e. which cell lines have an enrichment in which pathways / targets.

Log-Odds Heatmap

I create a heatmap of the enrichment (log odds ratio) to determine which pathways and targets are enriched in each cell line

heatmap_pathways = oddsratio_pathway[, c("Line", "Label", "OddsRatio")]
heatmap_pathways = acast(
  data = heatmap_pathways, 
  formula = Line ~ Label, value.var = "OddsRatio", 
  fun.aggregate = max, fill = 0)
# Replace Inf with the finite maximum
heatmap_pathways[is.infinite(heatmap_pathways)] = max(
  heatmap_pathways[!is.infinite(heatmap_pathways)])
heatmap_pathways[heatmap_pathways != 0] = log2(
  heatmap_pathways[heatmap_pathways != 0])
hc_pathways = as.dist((1 - cor(heatmap_pathways)) / 2)
hc_pathways_line = as.dist((1 - cor(t(heatmap_pathways))) / 2)

heatmap_targets = oddsratio_target[, c("Line", "Label", "OddsRatio")]
heatmap_targets = acast(
  data = heatmap_targets, 
  formula = Line ~ Label, value.var = "OddsRatio", 
  fun.aggregate = max, fill = 0)
# Replace Inf with the finite maximum
heatmap_targets[is.infinite(heatmap_targets)] = max(
  heatmap_targets[!is.infinite(heatmap_targets)])
heatmap_targets[heatmap_targets != 0] = log2(
  heatmap_targets[heatmap_targets != 0])
hc_targets = as.dist((1 - cor(heatmap_targets)) / 2)
hc_targets_line = as.dist((1 - cor(t(heatmap_targets))) / 2)

# hm_colorscale = colorRampPalette(
#   c('#b2182b','#d6604d','#f4a582', '#f7f7f7','#f7f7f7', '#f7f7f7',
#     '#f7f7f7', '#f7f7f7', '#f7f7f7'))(150)

hm_breaks = seq(0, max(heatmap_pathways, na.rm = TRUE), length.out = 50)
hm_colorscale = colorRampPalette(c("#f7f7f7", "#4575B4"))(length(hm_breaks))
pheatmap(
  heatmap_pathways, cluster_rows = hc_pathways_line, 
  cluster_cols = hc_pathways, 
  breaks = hm_breaks, color = hm_colorscale, 
  cellwidth = 10, cellheight = 10)

if(save_images) {
  pheatmap(
    heatmap_pathways, cluster_rows = hc_pathways_line, 
    cluster_cols = hc_pathways,
    breaks = hm_breaks, color = hm_colorscale, 
    cellwidth = 10, cellheight = 10, 
    filename = file.path(img_out_dir, "Heatmap_LogOdds_Pathways.pdf"))
}

hm_breaks = seq(0, max(heatmap_targets, na.rm = TRUE), length.out = 50)
hm_colorscale = colorRampPalette(c("#f7f7f7", "#4575B4"))(length(hm_breaks))
pheatmap(
  heatmap_targets, cluster_rows = hc_targets_line, 
  cluster_cols = hc_targets,
  breaks = hm_breaks, color = hm_colorscale, 
  cellwidth = 10, cellheight = 10)

if(save_images) {
  pheatmap(
    heatmap_targets, cluster_rows = hc_targets_line, 
    cluster_cols = hc_targets,
    breaks = hm_breaks, color = hm_colorscale, 
    cellwidth = 10, cellheight = 10, 
    filename = file.path(img_out_dir, "Heatmap_LogOdds_Targets.pdf"))
}

Binary Heatmap

binary_heatmap_pathways = heatmap_pathways
binary_heatmap_pathways[binary_heatmap_pathways > 0] = 1
binary_heatmap_targets = heatmap_targets
binary_heatmap_targets[binary_heatmap_targets > 0] = 1

hm_colorscale = colorRampPalette(c("#f7f7f7", "#4575B4"))(2)
pheatmap(
  binary_heatmap_pathways, cluster_rows = hc_pathways_line, 
  cluster_cols = hc_pathways, 
  color = hm_colorscale, legend = FALSE,
  cellwidth = 10, cellheight = 10)

pheatmap(
  binary_heatmap_targets, cluster_rows = hc_targets_line, 
  cluster_cols = hc_targets,
  color = hm_colorscale, legend = FALSE,
  cellwidth = 10, cellheight = 10)

if(save_images) {
  pheatmap(
    binary_heatmap_pathways, cluster_rows = hc_pathways_line, 
    cluster_cols = hc_pathways,
    color = hm_colorscale, legend = FALSE,
    cellwidth = 10, cellheight = 10, 
    filename = file.path(img_out_dir, "Heatmap_Binary_Pathways.pdf"))
  pheatmap(
    binary_heatmap_targets, cluster_rows = hc_targets_line, 
    cluster_cols = hc_targets,
    color = hm_colorscale, legend = FALSE,
    cellwidth = 10, cellheight = 10,
    filename = file.path(img_out_dir, "Heatmap_Binary_Targets.pdf"))
}

Feature Differences

I look at the vectors from median DMSO to median drug features for each drug per replicate. I use the well-averaged features to improve loading times. For each line, I aggregate all drugs belonging to the enriched clusters.

# Extract only key features
key_features = c(
  "x.0.s.area_expected" = "Area", 
  "x.0.m.eccentricity_expected" = "Eccentricity", 
  "x.a.b.q05_expected" = "Median Actin Intensity", 
  "x.b.b.q05_expected" = "Median FITC Intensity", 
  "x.c.b.q05_expected" = "Median DAPI Intensity") 

# Set up color scale
pheno_color_scale = c(
  "Median Actin Intensity" = "#e6194b",
  "Median FITC Intensity" = "#3cb44b", 
  "Median DAPI Intensity" = "#0082c8", 
  "Area" = "#ffe119", 
  "Eccentricity" = "#f58231")

# Load features
data("well_features", package = "SCOPEAnalysis")
well_features = well_features[, names(key_features)]

# Z-Scale features for each line and replicate
for(line in unique(well_metadata$Line)) {
  for(r in unique(well_metadata$Replicate)) {
    rep_sel = well_metadata$Line == line & well_metadata$Replicate == r
    well_features[rep_sel, ] = apply(
      X = well_features[rep_sel, ], 
      MARGIN = 2, FUN = function(x) (x - median(x)) / mad(x))
  }
}

# Subtract DMSO medians for each line and replicate
for(line in unique(well_metadata$Line)) {
  for(r in unique(well_metadata$Replicate)) {
    rep_sel = well_metadata$Line == line & well_metadata$Replicate == r
    rep_line_dmso_median = apply(
      X = well_features[rep_sel & well_metadata$Drug == "DMSO", ], 
      MARGIN = 2, FUN = median, na.rm = TRUE)
    well_features[rep_sel, ] = sweep(
      x = well_features[rep_sel, ], 
      MARGIN = 2, STATS = rep_line_dmso_median, FUN = "-")
  }
}

# Aggregate features for pathways for each line and replicate
all_pathway_features = list()
all_target_features = list()
for(line in unique(well_metadata$Line)) {
  line_enriched_drugs = enriched_drugs[enriched_drugs$Line == line, ]
  line_enriched_pathways = unique(line_enriched_drugs[
    line_enriched_drugs$is.pathway.enriched, "Pathway"])
  line_enriched_targets = unique(line_enriched_drugs[
    line_enriched_drugs$is.target.enriched, "Enriched.Target"])
  
  # Pathways
  for(pathway in line_enriched_pathways) {
    drugs = line_enriched_drugs[
      line_enriched_drugs$Pathway == pathway & 
      line_enriched_drugs$is.pathway.enriched, ]
    sel_indices = well_metadata$Drug %in% drugs$Drug & well_metadata$Line == line
    relevant_features = well_features[sel_indices, ]
    relevant_metadata = well_metadata[sel_indices, ]
    # Aggregate
    pathway_features = aggregate(
      x = relevant_features, 
      by = list("Replicate" = relevant_metadata$Replicate), 
      FUN = median)
    pathway_features$Line = line
    pathway_features$Label = pathway
    all_pathway_features[[length(all_pathway_features) + 1]] = pathway_features
  }
  
  # Targets
  for(target in line_enriched_targets) {
    drugs = line_enriched_drugs[
      line_enriched_drugs$Enriched.Target == target & 
      line_enriched_drugs$is.target.enriched, ]
    sel_indices = well_metadata$Drug %in% drugs$Drug & well_metadata$Line == line
    relevant_features = well_features[sel_indices, ]
    relevant_metadata = well_metadata[sel_indices, ]
    # Aggregate
    target_features = aggregate(
      x = relevant_features, 
      by = list("Replicate" = relevant_metadata$Replicate), 
      FUN = median)
    target_features$Line = line
    target_features$Label = target
    all_target_features[[length(all_target_features) + 1]] = target_features
  }
}
all_pathway_features = do.call(rbind, all_pathway_features)
all_target_features = do.call(rbind, all_target_features)

Phenoprints for Pathways

for(line in unique(all_pathway_features$Line)) {
  labels = unique(all_pathway_features[
    all_pathway_features$Line == line, "Label"])
  for(label in labels) {
    ggplot_df = all_pathway_features[all_pathway_features$Line == line & 
                                     all_pathway_features$Label == label, ]
    ggplot_df$Line = NULL
    ggplot_df$Label = NULL
    ggplot_df = melt(ggplot_df, id.vars = c("Replicate"))
    ggplot_df$variable = key_features[ggplot_df$variable]
    ggplot_df$variable = factor(ggplot_df$variable, levels = key_features)
    ggplot_df_bar = aggregate(
      x = ggplot_df$value, 
      by = list("variable" = ggplot_df$variable), 
      FUN = median)
    colnames(ggplot_df_bar) = c("variable", "value")
    gp = ggplot(mapping = aes(x = variable, y = value)) + 
      geom_col(data = ggplot_df_bar, mapping = aes(fill = variable)) + 
      geom_point(data = ggplot_df) + 
      scale_fill_manual(values = pheno_color_scale) + 
      theme_vignette() + coord_fixed() + 
      theme(
        axis.text.x = element_blank(), axis.line.x = element_blank(), 
        axis.ticks.x = element_blank(), legend.title = element_blank()) + 
      xlab("") + ylab("") + ggtitle(paste0(line, " ", label))
    plot(gp)
    if(save_images) ggsave(
      filename = file.path(img_out_dir, sprintf(
        "Phenoprints_Pathways_%s_%s.pdf", line, make.names(label))), 
      width = 5, height = 5, useDingbats = FALSE)
  }
}

Phenoprints for Targets

for(line in unique(all_target_features$Line)) {
  labels = unique(all_target_features[
    all_target_features$Line == line, "Label"])
  for(label in labels) {
    ggplot_df = all_target_features[all_target_features$Line == line & 
                                     all_target_features$Label == label, ]
    ggplot_df$Line = NULL
    ggplot_df$Label = NULL
    ggplot_df = melt(ggplot_df, id.vars = c("Replicate"))
    ggplot_df$variable = key_features[ggplot_df$variable]
    ggplot_df$variable = factor(ggplot_df$variable, levels = key_features)
    ggplot_df_bar = aggregate(
      x = ggplot_df$value, 
      by = list("variable" = ggplot_df$variable), 
      FUN = median)
    colnames(ggplot_df_bar) = c("variable", "value")
    gp = ggplot(mapping = aes(x = variable, y = value)) + 
      geom_col(data = ggplot_df_bar, mapping = aes(fill = variable)) + 
      geom_point(data = ggplot_df) + 
      scale_fill_manual(values = pheno_color_scale) + 
      theme_vignette() + coord_fixed() + 
      theme(
        axis.text.x = element_blank(), axis.line.x = element_blank(), 
        axis.ticks.x = element_blank(), legend.title = element_blank()) + 
      xlab("") + ylab("") + ggtitle(paste0(line, " ", label))
    plot(gp)
    if(save_images) ggsave(
      filename = file.path(img_out_dir, sprintf(
        "Phenoprints_Targets_%s_%s.pdf", line, make.names(label))), 
      width = 5, height = 5, useDingbats = FALSE)
  }
}

Drug Effect Differences across all Lines

Comparing Drug Effects Directly

Treating effect vectors of all drugs and all lines equally shows that drug effects on different lines are difficult to compare to each other. Line heterogeneity appears to overpower the effects of drugs. Even the drugs classified as lethal do not cluster together. Notable is that the lines D046T01 and D055T01, which look extremely similar on visual inspection, DO overlap.

## overwriting objects to remove dropped lines
profiles_active <- profiles_active %>% rownames_to_column("id") %>% mutate(line = substr(id, 1, 7)) %>%
  dplyr::filter(!line %in% c("D021T01", "D054T01", "D055T01")) %>% dplyr::select(-line) %>%
  column_to_rownames("id")

angles = get_angles(profiles_active)
d = acos(angles)*180/pi
hc = hclust(as.dist(d), method = "ward.D2")

cor_pca = cor(profiles_active)
d_pca = as.dist((1 - cor_pca) / 2)
hc_pca = hclust(d_pca, method = "ward.D2")

killing_anno = rep(NA, nrow(metadata_active))
killing_anno[metadata_active$Viability <= 0.2] = "0.2"
killing_anno[
  metadata_active$Viability > 0.2 & 
  metadata_active$Viability <= 0.4] = "0.4"
killing_anno[
  metadata_active$Viability > 0.4 & 
  metadata_active$Viability <= 0.6] = "0.6"
killing_anno[
  metadata_active$Viability > 0.6 & 
  metadata_active$Viability <= 0.8] = "0.8"
killing_anno[
  metadata_active$Viability > 0.8 & 
  metadata_active$Viability <= 1] = "1"

annotation = data.frame(
  "Viability" = killing_anno,
  "Pathway" = get_mode_of_action(metadata_active$Drug),
  "Target" = get_targets(metadata_active$Drug),
  "Line" = metadata_active$Line,
  #row.names = rownames(profiles_active),
  stringsAsFactors = FALSE)

# dropping lines
annotation <- annotation %>% dplyr::filter(!Line %in% c("D021T01", "D054T01", "D055T01"))
rownames(annotation) <- rownames(profiles_active)

# Annotate Pathway and Targets
pathways = list()
for(pathway in unique(annotation$Pathway)) {
  pathways[[pathway]] = grep(
    pattern = paste0("\\b", pathway, "\\b"), 
    x = annotation$Pathway, 
    ignore.case = TRUE)
}
# My cluster_enrichment function doesn't play well with NA values yet
pathways = pathways[!is.na(names(pathways))]
pathways_sig_vec = get_cluster_enrichment(
  clustering = hc, labels = pathways, min_cluster_size = min_cluster_size)
# 'Others' is too vague
pathways_sig_vec$Labels[pathways_sig_vec$Labels == "Others"] = NA

targets_split = tolower(annotation$Target)
targets = list()
for(target in unique(unlist(strsplit(targets_split, ", ")))) {
  targets[[target]] = grep(
    pattern = paste0("\\b", target, "\\b"), 
    x = targets_split, ignore.case = TRUE)
}
# My cluster_enrichment function doesn't play well with NA values yet
targets = targets[!is.na(names(targets))]
targets_sig_vec = get_cluster_enrichment(
  clustering = hc, labels = targets, min_cluster_size = min_cluster_size)

annotation$Pathway = pathways_sig_vec$Labels
annotation$Target = targets_sig_vec$Labels

# Set up colors
anno_colorScale = list(
  "Viability" = setNames(
    object = colorRampPalette(c("black", "white"))(
      length(unique(annotation$Viability))), 
    nm = sort(unique(annotation$Viability))))
if(sum(!is.na(annotation$Pathway)) == 0) annotation$Pathway = NULL
if(sum(!is.na(annotation$Target)) == 0) annotation$Target = NULL
for(column in colnames(annotation)) {
  if(column %in% names(anno_colorScale)) next
  entries = na.omit(unique(annotation[[column]]))
  anno_colorScale[[column]] = setNames(
    object = unname(colorScale)[seq_along(entries)], 
    nm = entries)
}

# Set up heatmap color scale
sqrt_profiles = profiles_active
sqrt_profiles[sqrt_profiles > 0] = sqrt(sqrt_profiles[sqrt_profiles > 0])
sqrt_profiles[sqrt_profiles < 0] = -sqrt(-sqrt_profiles[sqrt_profiles < 0])
hm_range_limit = max(abs(sqrt_profiles))
hm_breaks = seq(-hm_range_limit, hm_range_limit, length.out = 100)
hm_legend_breaks = c(-floor(hm_range_limit), 0, floor(hm_range_limit))
hm_legend_labels = hm_legend_breaks**2
hm_legend_labels[hm_legend_breaks < 0] = -hm_legend_labels[hm_legend_breaks < 0]
hm_colorscale = colorRampPalette(
  c("#0082c8", "white", "#e6194b"))(length(hm_breaks))

pheatmap(
  mat = t(profiles_active), cluster_rows = hc_pca, cluster_cols = hc, 
  show_colnames = FALSE, annotation_col = annotation, breaks = hm_breaks,
  legend_breaks = hm_legend_breaks, legend_labels = hm_legend_labels, 
  color = hm_colorscale, annotation_colors = anno_colorScale, 
  cellwidth = 0.1, cellheight = 7)

if(save_images) pheatmap(
  mat = t(profiles_active), cluster_rows = hc_pca, cluster_cols = hc, 
  show_colnames = FALSE, annotation_col = annotation, breaks = hm_breaks,
  legend_breaks = hm_legend_breaks, legend_labels = hm_legend_labels, 
  color = hm_colorscale, annotation_colors = anno_colorScale, 
  cellwidth = 0.2, cellheight = 7, width = 10, height = 10, 
  filename = file.path(
    img_out_dir, "EffectVectorHeatmap_allDrugs_noConcat_PCA.pdf"))

 hm_colorscale = colorRampPalette(
    rev(c("#f7f7f7", "#f7f7f7", "#f7f7f7", 
          "#E0F3F8", "#91BFDB", "#4575B4")))(150)

pheatmap(
  mat = d, cluster_rows = hc, cluster_cols = hc, color = hm_colorscale,
  show_colnames = FALSE, show_rownames = FALSE, 
  annotation_col = annotation, annotation_colors = anno_colorScale, 
  cellwidth = 0.1, cellheight = 0.1)

if(save_images) pheatmap(
  mat = d, cluster_rows = hc, cluster_cols = hc, color = hm_colorscale,
  show_colnames = FALSE, show_rownames = FALSE, 
  annotation_col = annotation, annotation_colors = anno_colorScale, 
  cellwidth = 0.1, cellheight = 0.1, height = 10, 
  filename = file.path(
    img_out_dir, "EffectVectorHeatmap_allDrugs_noConcat.pdf"))

There is one notably enriched cluster of mTOR inhibitors, in particular the drug “AZD2014” is enriched in 11 cell lines, as well several times in the pan-cell line clustering.

sel_indices = metadata_active$Drug == "AZD2014"
drug_profiles = profiles_active[sel_indices, ]
drug_annotation = annotation[sel_indices, ]

angles_drug = get_angles(drug_profiles)
d_drug = acos(angles_drug) * 180 / pi
hc_drug = hclust(as.dist(d_drug), method = "ward.D2")

hm_colorscale = colorRampPalette(
  rev(c("#f7f7f7", "#E0F3F8", "#91BFDB", "#4575B4")))(150)

pheatmap(
  mat = d_drug, cluster_rows = hc_drug, cluster_cols = hc_drug, 
  color = hm_colorscale, labels_row = drug_annotation$Line, 
  show_colnames = FALSE)

Concatenating Vectors

Instead of treating each drug per line separately, I concatenate the effect vectors on all lines for each drug. The resulting composite vector describes the drug’s effect on all cell lines without attempting to compare cell lines.

## TODO dropping filtered line
loi <- sort(unique(metadata_active$Line))[!c(sort(unique(metadata_active$Line))%in% c("D021T01", "D055T01", "D054T01"))]

profiles_concat = list()
for(drug in sort(unique(metadata_active$Drug))) {
# for(drug in sort(unique(metadata$Drug))) {
  profiles_concat_drug = c()
  for(line in loi) {
  # for(line in sort(unique(metadata$Line))) {
    tmp = profiles[
      metadata$Drug == drug & 
      metadata$Line == line, , drop = FALSE]
    if(is.null(nrow(tmp))) stop("Critical Error: the code expects a matrix")
    if(nrow(tmp) == 0) {
      tmp = matrix(
        data = NA, nrow = 1, ncol = n_components, 
        dimnames = list(drug, paste0(line, ".", colnames(tmp))))
    } else if(nrow(tmp) > 1) {
      tmp = matrix(
        colMeans(tmp), nrow=1, 
        dimnames = list(drug, paste0(line, ".", colnames(tmp))))
    } else {
      rownames(tmp) = drug
      colnames(tmp) = paste0(line, ".", colnames(tmp))
    }
    profiles_concat_drug = cbind(profiles_concat_drug, as.matrix(tmp))
  }
  profiles_concat[[drug]] = data.frame(
    profiles_concat_drug)
}
profiles_concat = do.call(rbind, profiles_concat)

# Impute missing values with the means for the corresponding PC of all other 
# lines for that drug
missing_drugs = which(is.na(profiles_concat), arr.ind = T)
for(ii in seq_len(nrow(missing_drugs))) {
  entry = missing_drugs[ii, ]
  pc = strsplit(colnames(profiles_concat)[entry[2]], ".", fixed = TRUE)[[1]][2]
  other_pc_cols = sapply(
    strsplit(colnames(profiles_concat), ".", fixed = TRUE), 
    "[[", 2) == pc
  mean_val = mean(as.numeric(
    profiles_concat[entry[1], other_pc_cols]), na.rm = TRUE)
  profiles_concat[entry[1], entry[2]] = mean_val
}

# If a drug has no effect in a line, I set its respective PC values to 0
# for(drug in rownames(profiles_concat)) {
#   for(line in sort(unique(metadata_active$Line))) {
#     drug_is_active = metadata$AUC_Mean[
#       metadata$Line == line & 
#       metadata$Drug == drug] >= auc_thresh
#     if(length(drug_is_active) == 0) next
#     if(!drug_is_active) profiles_concat[
#       drug, substr(colnames(profiles_concat), 1, 7) == line] = 0
#   }
# }

# Cluster
angles = get_angles(profiles_concat)
d = acos(angles) * 180 / pi
hc = hclust(as.dist(d), method = "ward.D2")

annotation = data.frame(
  "Pathway" = get_mode_of_action(rownames(profiles_concat)),
  "Target" = get_targets(rownames(profiles_concat)),
  row.names = rownames(profiles_concat),
  stringsAsFactors = FALSE)

# Annotate Pathway and Targets
pathways = list()
for(pathway in unique(annotation$Pathway)) {
  pathways[[pathway]] = grep(
    pattern = paste0("\\b", pathway, "\\b"), 
    x = annotation$Pathway, 
    ignore.case = TRUE)
}
pathways_sig_vec = get_cluster_enrichment(
  clustering = hc, labels = pathways, min_cluster_size = min_cluster_size)
# 'Others' is too vague
pathways_sig_vec$Labels[pathways_sig_vec$Labels == "Others"] = NA

targets_split = tolower(annotation$Target)
targets = list()
for(target in unique(unlist(strsplit(targets_split, ", ")))) {
  targets[[target]] = grep(
    pattern = paste0("\\b", target, "\\b"), 
    x = targets_split, ignore.case = TRUE)
}
targets_sig_vec = get_cluster_enrichment(
  clustering = hc, labels = targets, min_cluster_size = min_cluster_size)

annotation$Pathway = pathways_sig_vec$Labels
annotation$Target = targets_sig_vec$Labels

if(sum(!is.na(annotation$Pathway)) == 0) annotation$Pathway = NULL
if(sum(!is.na(annotation$Target)) == 0) annotation$Target = NULL

# Add a summary statistic for lethality
lethality_degree = aggregate(
  x = metadata$Viability <= 0.25, 
  by = list("Drug" = metadata$Drug), 
  FUN = sum)
rownames(lethality_degree) = lethality_degree$Drug
lethality_degree$Drug = NULL
# Hack to normalize number of lethal lines for positive controls
lethality_degree$x[lethality_degree$x > length(unique(metadata$Line))] = length(unique(metadata$Line))
annotation$Lethality = lethality_degree[rownames(annotation), "x"]

# Set up colors
anno_colorScale = list()
for(column in colnames(annotation)) {
  if(column %in% names(anno_colorScale)) next
  entries = sort(na.omit(unique(annotation[[column]])))
  anno_colorScale[[column]] = setNames(
    object = unname(colorScale)[seq_along(entries)], 
    nm = entries)
}
anno_colorScale$Lethality = colorRampPalette(
  c("white", "black"))(length(anno_colorScale$Lethality))

# hm_colorscale = colorRampPalette(
#   rev(c("#f7f7f7", "#f7f7f7", "#f7f7f7", "#f7f7f7",
#         "#E0F3F8", "#91BFDB", "#4575B4")))(150)

hm_colorscale = colorRampPalette(
  rev(c("#f7f7f7", "#E0F3F8", "#91BFDB", "#4575B4")))(150)

anno_colorScale$Target = setNames(
  object = c("#e6194b", "#3cb44b", "#ffe119", "#0082c8", "#f58231", 
             "#911eb4", "#46f0f0", "#f032e6", "#d2f53c", "#fabebe", 
             "#008080", "#e6beff", "#aa6e28", "#fffac8", "#800000", 
             "#aaffc3", "#808000", "#ffd8b1", "#000080", "#808080", 
             "#d0d0d0", "#000000"), 
  nm = names(anno_colorScale$Target))

pheatmap(
    mat = d, annotation_col = annotation, 
    color = hm_colorscale, annotation_colors = anno_colorScale, 
    show_rownames = FALSE, show_colnames = FALSE, 
    cluster_rows = hc, cluster_cols = hc, 
    main = "Angles Between Profile Vectors for All Lines", 
    border_color = NA)

if(save_images) pheatmap(
    d, annotation_col = annotation, 
    color = hm_colorscale, annotation_colors = anno_colorScale, 
    show_rownames = FALSE, show_colnames = FALSE, 
    cluster_rows = hc, cluster_cols = hc, 
    main = sprintf("Angles Between Profile Vectors for all lines"), 
    border_color = NA, cellwidth = 1.5, cellheight = 1.5, height = 15, 
    filename = file.path(img_out_dir, "EffectVectorHeatmap_allDrugs.pdf"))

Shown are the individual drug viabilities for each line according to the clustering for the drug effects to further showcase the compatibility between the methods

active_drugs = rownames(d)
active_viabilities = metadata[metadata$Drug %in% active_drugs, ]

# Aggregate drugs over wells
active_viabilities = aggregate(
  x = active_viabilities$Viability, 
  by = list("Drug" = active_viabilities$Drug, 
            "Line" = active_viabilities$Line), 
  FUN = median, na.rm = TRUE)

active_viabilities = acast(
  data = active_viabilities, 
  formula = Line ~ Drug, value.var = "x")

## TODO drop lines
active_viabilities = active_viabilities[!c(active_viabilities %>% rownames() %in% c("D021T01", "D055T01", "D054T01")),]

# Remove viability from annotation
anno_noLethality = annotation
anno_noLethality$Lethality = NULL
anno_colorScale$Lethality = NULL

pheatmap(
    mat = active_viabilities, annotation_col = anno_noLethality, 
    color = hm_colorscale, annotation_colors = anno_colorScale, 
    show_rownames = TRUE, show_colnames = FALSE, 
    cluster_rows = TRUE, cluster_cols = hc, 
    main = "Induced Viabilities of Drugs", 
    border_color = NA)

if(save_images) pheatmap(
    mat = active_viabilities, annotation_col = anno_noLethality, 
    color = hm_colorscale, annotation_colors = anno_colorScale, 
    show_rownames = TRUE, show_colnames = FALSE, 
    cluster_rows = TRUE, cluster_cols = hc, 
    main = "Induced Viabilities of Drugs", 
    border_color = NA, cellwidth = 1.5, cellheight = 10, height = 15, 
    filename = file.path(img_out_dir, "EffectVectorHeatmap_Viabilities_allDrugs.pdf"))

Generate a list of column/row names with annotations

annotation_table = annotation[hc$labels[hc$order], ]
colnames(annotation_table) = c(
  "EnrichedPathway", "EnrichedTarget", "Lethality")
annotation_table$Pathway = get_mode_of_action(rownames(annotation_table))
annotation_table$Targets = tolower(get_targets(rownames(annotation_table)))
annotation_table = annotation_table[, c(
  "Pathway", "Targets", "EnrichedPathway", "EnrichedTarget", "Lethality")]
print(annotation_table)
##                                                       Pathway
## Ulixertinib (BVD-523, VRT752271)                         MAPK
## TAK-733                                                  MAPK
## Trametinib (GSK1120212)                                  MAPK
## Cobimetinib (GDC-0973, RG7420)                           MAPK
## MEK162 (ARRY-162, ARRY-438162)                           MAPK
## Selumetinib (AZD6244)                                    MAPK
## Refametinib (RDEA119, Bay 86-9766)                     Others
## AZD8330                                                  MAPK
## Pimasertib (AS-703026)                                   MAPK
## RAF265 (CHIR-265)                                        MAPK
## PD184352 (CI-1040)                                       MAPK
## PD318088                                                 MAPK
## PD0325901                                          DNA Damage
## VX-11e                                                   MAPK
## Alisertib (MLN8237)                                    Others
## GSK2292767                                      PI3K/Akt/mTOR
## Hesperadin                                         Cell Cycle
## KW-2449                                          Angiogenesis
## PF-4708671                                      PI3K/Akt/mTOR
## BMS-754807                                             Others
## LY3023414                                       PI3K/Akt/mTOR
## Crizotinib (PF-02341066)                               Others
## ENMD-2076                                        Angiogenesis
## HMN-214                                            Cell Cycle
## BKM120 (NVP-BKM120, Buparlisib)                 PI3K/Akt/mTOR
## NVP-AEW541                            Protein Tyrosine Kinase
## AZ 960                                               JAK/STAT
## GSK2636771                                      PI3K/Akt/mTOR
## RepSox                                          TGF-beta/Smad
## Foretinib (GSK1363089)                                 Others
## Danusertib (PHA-739358)                                Others
## SNS-314 Mesylate                                       Others
## CYC116                                             Cell Cycle
## VX-680 (Tozasertib, MK-0457)         Endocrinology & Hormones
## AZD1480                                              JAK/STAT
## BX-912                                          PI3K/Akt/mTOR
## PD173955                                         Angiogenesis
## TPCA-1                                                  NF-_B
## AZD7762                                            Cell Cycle
## Rigosertib (ON-01910)                              Cell Cycle
## BI 2536                                                Others
## Flavopiridol (Alvocidib)                           Cell Cycle
## AT7519                                             Cell Cycle
## SNS-032 (BMS-387032)                                   Others
## CUDC-907                               Cytoskeletal Signaling
## Irinotecan / SN-38                                       <NA>
## JNJ-7706621                                        Cell Cycle
## CHIR-124                                           Cell Cycle
## Pacritinib (SB1518)                                  JAK/STAT
## CUDC-101                                          Epigenetics
## AT9283                                                 Others
## GSK461364                                          Cell Cycle
## BGT226 (NVP-BGT226)                             PI3K/Akt/mTOR
## Bortezomib                                               <NA>
## Staurosporine_500nM                                      <NA>
## IMD 0354                                                NF-_B
## Triciribine                                            Others
## FRAX597                                Cytoskeletal Signaling
## Golvatinib (E7050)                    Protein Tyrosine Kinase
## Tepotinib (EMD 1214063)               Protein Tyrosine Kinase
## IKK-16 (IKK Inhibitor VII)                              NF-_B
## LDK378                                Protein Tyrosine Kinase
## AMG-900                                            Cell Cycle
## KX2-391                                          Angiogenesis
## JNK Inhibitor IX                                         MAPK
## Tivantinib (ARQ 197)                  Protein Tyrosine Kinase
## VE-822                                          PI3K/Akt/mTOR
## HS-173                                          PI3K/Akt/mTOR
## Wnt agonist 1                               Stem Cells &  Wnt
## AZ20                                            PI3K/Akt/mTOR
## AZD6738                                         PI3K/Akt/mTOR
## Ro 31-8220 Mesylate                             TGF-beta/Smad
## Ro3280                                             Cell Cycle
## PF-3758309                             Cytoskeletal Signaling
## PF-00562271                                      Angiogenesis
## PF-562271                                        Angiogenesis
## R547                                               Cell Cycle
## Flavopiridol HCl                                   Cell Cycle
## PHA-767491                                         Cell Cycle
## AZD5438                                            Cell Cycle
## A-674563                                        PI3K/Akt/mTOR
## Dinaciclib (SCH727965)                             Cell Cycle
## P276-00                                            Cell Cycle
## AP26113                               Protein Tyrosine Kinase
## SC1                                                      MAPK
## AZD3463                               Protein Tyrosine Kinase
## GSK2126458 (GSK458)                             PI3K/Akt/mTOR
## Torin 2                                         PI3K/Akt/mTOR
## SGI-7079                              Protein Tyrosine Kinase
## PF-431396                                        Angiogenesis
## TAE226 (NVP-TAE226)                              Angiogenesis
## Milciclib (PHA-848125)                             Cell Cycle
## TG101209                                             JAK/STAT
## TG101348 (SAR302503)                                 JAK/STAT
## CO-1686 (AVL-301)                     Protein Tyrosine Kinase
## Entrectinib (RXDX-101)                Protein Tyrosine Kinase
## A66                                             PI3K/Akt/mTOR
## BYL719                                          PI3K/Akt/mTOR
## AVL-292                                          Angiogenesis
## Akti-1/2                                        PI3K/Akt/mTOR
## WAY-600                                         PI3K/Akt/mTOR
## AZD8055                                         PI3K/Akt/mTOR
## CH5132799                                       PI3K/Akt/mTOR
## WYE-125132 (WYE-132)                            PI3K/Akt/mTOR
## PF-04691502                                     PI3K/Akt/mTOR
## PP121                                 Protein Tyrosine Kinase
## GDC-0980 (RG7422)                               PI3K/Akt/mTOR
## INK 128 (MLN0128)                               PI3K/Akt/mTOR
## VS-5584 (SB2343)                                PI3K/Akt/mTOR
## CCT128930                                       PI3K/Akt/mTOR
## GDC-0068                                        PI3K/Akt/mTOR
## ETP-46464                                       PI3K/Akt/mTOR
## AZD2014                                         PI3K/Akt/mTOR
## GDC-0349                                        PI3K/Akt/mTOR
## GSK2334470                                      PI3K/Akt/mTOR
## OSI-027                                         PI3K/Akt/mTOR
## BMS-536924                            Protein Tyrosine Kinase
## MK-2206 2HCl                                           Others
## OSI-906 (Linsitinib)                                   Others
## ZSTK474                                    Neuronal Signaling
## KU-0063794                                      PI3K/Akt/mTOR
## WYE-354                                         PI3K/Akt/mTOR
## CC-223                                          PI3K/Akt/mTOR
## PP242                                           PI3K/Akt/mTOR
## GSK690693                                              Others
## AZD5363                                         PI3K/Akt/mTOR
## Uprosertib (GSK2141795)                         PI3K/Akt/mTOR
## AT13148                                         PI3K/Akt/mTOR
## AT7867                                          PI3K/Akt/mTOR
## Temsirolimus (CCI-779, NSC 683864)         Neuronal Signaling
## Everolimus (RAD001)                                    Others
## Ridaforolimus (Deforolimus, MK-8669)            PI3K/Akt/mTOR
## Ibrutinib (PCI-32765)                            Angiogenesis
## ONO-4059                                         Angiogenesis
## AG-1478 (Tyrphostin AG-1478)          Protein Tyrosine Kinase
## ZM 306416                             Protein Tyrosine Kinase
## CNX-2006                              Protein Tyrosine Kinase
## PD168393                              Protein Tyrosine Kinase
## AZD3759                               Protein Tyrosine Kinase
## Dacomitinib (PF299804, PF299)         Protein Tyrosine Kinase
## Saracatinib (AZD0530)                            Angiogenesis
## Gefitinib (ZD1839)                    Protein Tyrosine Kinase
## OSI-420                               Protein Tyrosine Kinase
## AZD8931 (Sapitinib)                   Protein Tyrosine Kinase
## Pelitinib (EKB-569)                   Protein Tyrosine Kinase
## AST-1306                              Protein Tyrosine Kinase
## Imatinib Mesylate (STI571)            Protein Tyrosine Kinase
## Vacquinol-1                                              MAPK
## AEE788 (NVP-AEE788)                   Protein Tyrosine Kinase
## WZ3146                                Protein Tyrosine Kinase
## SGI-1776 free base                                   JAK/STAT
## CHIR-99021 (CT99021)                            PI3K/Akt/mTOR
## PIK-93                                          PI3K/Akt/mTOR
## LY2090314                                       PI3K/Akt/mTOR
## AZD2858                                         PI3K/Akt/mTOR
## CHIR-98014                                      PI3K/Akt/mTOR
## AZD1080                                         PI3K/Akt/mTOR
## CHIR-99021 (CT99021) HCl                        PI3K/Akt/mTOR
## 1-Azakenpaullone                                PI3K/Akt/mTOR
## Enzastaurin (LY317615)                     Neuronal Signaling
## Dabrafenib (GSK2118436)                                  MAPK
## MLN2480                                                  MAPK
## Piceatannol                                      Angiogenesis
## NVP-BHG712                            Protein Tyrosine Kinase
## YM201636                                        PI3K/Akt/mTOR
## Sotrastaurin                                    TGF-beta/Smad
## AC480 (BMS-599626)                         Neuronal Signaling
## AZ 628                                                   MAPK
## LDN-214117                                      TGF-beta/Smad
## PP1                                              Angiogenesis
## PP2                                              Angiogenesis
## Mubritinib (TAK 165)                  Protein Tyrosine Kinase
## VPS34-IN1                                       PI3K/Akt/mTOR
## FH535                                       Stem Cells &  Wnt
## Tyrphostin 9                          Protein Tyrosine Kinase
## LGK-974                                     Stem Cells &  Wnt
## PQ 401                                Protein Tyrosine Kinase
## Tyrphostin AG 879                     Protein Tyrosine Kinase
## YO-01027                                            Proteases
## XMD8-92                                                  MAPK
## GF109203X                                       TGF-beta/Smad
## Go 6983                                         TGF-beta/Smad
## LY2835219                                          Cell Cycle
## ERK5-IN-1                                                MAPK
## CP-673451                             Protein Tyrosine Kinase
## Crenolanib (CP-868596)                Protein Tyrosine Kinase
## PF-543                                       GPCR & G Protein
## LDC000067                                          Cell Cycle
## PHA-793887                                         Cell Cycle
## AZD9291                               Protein Tyrosine Kinase
## GZD824                                           Angiogenesis
## JNK-IN-8                                                 MAPK
## Fostamatinib (R788)                              Angiogenesis
## TAK-901                                            Cell Cycle
## SU6656                                           Angiogenesis
## LY2784544                                            JAK/STAT
## SU9516                                             Cell Cycle
## LY2603618                                          Cell Cycle
## PF-477736                                          Cell Cycle
## MK-5108 (VX-689)                                   Cell Cycle
## HTH-01-015                                      PI3K/Akt/mTOR
## MK-8745                                            Cell Cycle
## TAK-632                                                  MAPK
## GSK1838705A                           Protein Tyrosine Kinase
## BMS-345541                                              NF-_B
## Dovitinib (TKI-258) Dilactic Acid                Angiogenesis
## Pazopanib                             Protein Tyrosine Kinase
## Sorafenib                                                MAPK
## PRI-724                                     Stem Cells &  Wnt
## Nintedanib (BIBF 1120)_uncertain      Protein Tyrosine Kinase
## WIKI4                                       Stem Cells &  Wnt
## BIO                                             PI3K/Akt/mTOR
## Semaxanib (SU5416)                    Protein Tyrosine Kinase
## DCC-2036 (Rebastinib)                            Angiogenesis
## Purvalanol A                                       Cell Cycle
## CEP-33779                                            JAK/STAT
## ASP3026                               Protein Tyrosine Kinase
## WZ4003                                          PI3K/Akt/mTOR
## PD173074                                         Angiogenesis
## NVP-BSK805 2HCl                                      JAK/STAT
## AZD4547                                          Angiogenesis
## CX-6258 HCl                                          JAK/STAT
## Linifanib (ABT-869)                   Protein Tyrosine Kinase
## SU11274                                    Neuronal Signaling
## Sunitinib Malate                                 Microbiology
## ICG-001                                     Stem Cells &  Wnt
## K02288                                          TGF-beta/Smad
## TWS119                                          PI3K/Akt/mTOR
## Aurora A Inhibitor I                               Cell Cycle
## OSU-03012 (AR-12)                                      Others
## PHA-680632                                         Cell Cycle
## Barasertib (AZD1152-HQPA)                              Others
## ZM 447439                                              Others
## Dovitinib (TKI-258, CHIR-258)                    Angiogenesis
## Quizartinib (AC220)                              Angiogenesis
## PHA-665752                                             Others
## Axitinib                              Protein Tyrosine Kinase
## Bosutinib (SKI-606)                              Angiogenesis
## PRT062607 (P505-15, BIIB057) HCl                 Angiogenesis
## Sorafenib Tosylate                         Neuronal Signaling
## WH-4-023                                         Angiogenesis
## AG-1024                               Protein Tyrosine Kinase
## Amuvatinib (MP-470)                   Protein Tyrosine Kinase
## Lapatinib (GW-572016) Ditosylate      Protein Tyrosine Kinase
## Cediranib (AZD2171)                   Protein Tyrosine Kinase
## U0126-EtOH                                             Others
## Ponatinib (AP24534)                              Angiogenesis
## DASA-58                                                Others
## Dasatinib                                        Angiogenesis
## PF-573228                                        Angiogenesis
## BMS-265246                                         Cell Cycle
## KU-60019                                           DNA Damage
##                                                                       Targets
## Ulixertinib (BVD-523, VRT752271)                                          erk
## TAK-733                                                                   mek
## Trametinib (GSK1120212)                                                   mek
## Cobimetinib (GDC-0973, RG7420)                                            mek
## MEK162 (ARRY-162, ARRY-438162)                                            mek
## Selumetinib (AZD6244)                                                     mek
## Refametinib (RDEA119, Bay 86-9766)                                        mek
## AZD8330                                                                   mek
## Pimasertib (AS-703026)                                                    mek
## RAF265 (CHIR-265)                                                  raf, vegfr
## PD184352 (CI-1040)                                                        mek
## PD318088                                                                  mek
## PD0325901                                                                 mek
## VX-11e                                                                    erk
## Alisertib (MLN8237)                                             aurora kinase
## GSK2292767                                                               pi3k
## Hesperadin                                                      aurora kinase
## KW-2449                                           flt, bcr-abl, aurora kinase
## PF-4708671                                                          s6 kinase
## BMS-754807                                                             igf-1r
## LY3023414                                                                 akt
## Crizotinib (PF-02341066)                                           c-met, alk
## ENMD-2076                                           flt, aurora kinase, vegfr
## HMN-214                                                                   plk
## BKM120 (NVP-BKM120, Buparlisib)                                          pi3k
## NVP-AEW541                                                             igf-1r
## AZ 960                                                                    jak
## GSK2636771                                                               pi3k
## RepSox                                                          tgf-beta/smad
## Foretinib (GSK1363089)                                           c-met, vegfr
## Danusertib (PHA-739358)              aurora kinase, fgfr, bcr-abl, c-ret, src
## SNS-314 Mesylate                                                aurora kinase
## CYC116                                                   aurora kinase, vegfr
## VX-680 (Tozasertib, MK-0457)                                    aurora kinase
## AZD1480                                                                   jak
## BX-912                                                                  pdk-1
## PD173955                                                              bcr-abl
## TPCA-1                                                                    ikk
## AZD7762                                                                   chk
## Rigosertib (ON-01910)                                                     plk
## BI 2536                                                                   plk
## Flavopiridol (Alvocidib)                                                  cdk
## AT7519                                                                    cdk
## SNS-032 (BMS-387032)                                                      cdk
## CUDC-907                                                           hdac, pi3k
## Irinotecan / SN-38                                                     top1mt
## JNJ-7706621                                                cdk, aurora kinase
## CHIR-124                                                                  chk
## Pacritinib (SB1518)                                                       jak
## CUDC-101                                                     hdac, egfr, her2
## AT9283                                            bcr-abl, jak, aurora kinase
## GSK461364                                                                 plk
## BGT226 (NVP-BGT226)                                                pi3k, mtor
## Bortezomib                                                              psmb1
## Staurosporine_500nM                                                      <NA>
## IMD 0354                                                                  ikk
## Triciribine                                                               akt
## FRAX597                                                                   pak
## Golvatinib (E7050)                                               c-met, vegfr
## Tepotinib (EMD 1214063)                                                 c-met
## IKK-16 (IKK Inhibitor VII)                                                ikk
## LDK378                                                                    alk
## AMG-900                                                         aurora kinase
## KX2-391                                                                   src
## JNK Inhibitor IX                                                          jnk
## Tivantinib (ARQ 197)                                                    c-met
## VE-822                                                                atm/atr
## HS-173                                                                   pi3k
## Wnt agonist 1                                                wnt/beta-catenin
## AZ20                                                                  atm/atr
## AZD6738                                                               atm/atr
## Ro 31-8220 Mesylate                                                       pkc
## Ro3280                                                                    plk
## PF-3758309                                                                pak
## PF-00562271                                                               fak
## PF-562271                                                                 fak
## R547                                                                      cdk
## Flavopiridol HCl                                                          cdk
## PHA-767491                                                                cdk
## AZD5438                                                                   cdk
## A-674563                                                        akt, cdk, pka
## Dinaciclib (SCH727965)                                                    cdk
## P276-00                                                                   cdk
## AP26113                                                                   alk
## SC1                                                                       erk
## AZD3463                                                                   alk
## GSK2126458 (GSK458)                                                pi3k, mtor
## Torin 2                                                                  mtor
## SGI-7079                                                                vegfr
## PF-431396                                                                 fak
## TAE226 (NVP-TAE226)                                                       fak
## Milciclib (PHA-848125)                                                    cdk
## TG101209                                                      flt, jak, c-ret
## TG101348 (SAR302503)                                                      jak
## CO-1686 (AVL-301)                                                        egfr
## Entrectinib (RXDX-101)                                           trk receptor
## A66                                                                      pi3k
## BYL719                                                                   pi3k
## AVL-292                                                                   btk
## Akti-1/2                                                                  akt
## WAY-600                                                                  mtor
## AZD8055                                                                  mtor
## CH5132799                                                          pi3k, mtor
## WYE-125132 (WYE-132)                                                     mtor
## PF-04691502                                                   mtor, pi3k, akt
## PP121                                                      dna-pk, mtor, pdgf
## GDC-0980 (RG7422)                                                  mtor, pi3k
## INK 128 (MLN0128)                                                        mtor
## VS-5584 (SB2343)                                                         pi3k
## CCT128930                                                                 akt
## GDC-0068                                                                  akt
## ETP-46464                                                                mtor
## AZD2014                                                                  mtor
## GDC-0349                                                                 mtor
## GSK2334470                                                              pdk-1
## OSI-027                                                                  mtor
## BMS-536924                                                             igf-1r
## MK-2206 2HCl                                                              akt
## OSI-906 (Linsitinib)                                                   igf-1r
## ZSTK474                                                                  pi3k
## KU-0063794                                                               mtor
## WYE-354                                                                  mtor
## CC-223                                                                   mtor
## PP242                                                                    mtor
## GSK690693                                                                 akt
## AZD5363                                                                   akt
## Uprosertib (GSK2141795)                                                   akt
## AT13148                                                                   akt
## AT7867                                                         akt, s6 kinase
## Temsirolimus (CCI-779, NSC 683864)                                       mtor
## Everolimus (RAD001)                                                      mtor
## Ridaforolimus (Deforolimus, MK-8669)                                     mtor
## Ibrutinib (PCI-32765)                                                     src
## ONO-4059                                                                  btk
## AG-1478 (Tyrphostin AG-1478)                                             egfr
## ZM 306416                                                               vegfr
## CNX-2006                                                                 egfr
## PD168393                                                                 egfr
## AZD3759                                                                  egfr
## Dacomitinib (PF299804, PF299)                                            egfr
## Saracatinib (AZD0530)                                            src, bcr-abl
## Gefitinib (ZD1839)                                                       egfr
## OSI-420                                                                  egfr
## AZD8931 (Sapitinib)                                                egfr, her2
## Pelitinib (EKB-569)                                                      egfr
## AST-1306                                                                 egfr
## Imatinib Mesylate (STI571)                              pdgfr, c-kit, bcr-abl
## Vacquinol-1                                                               jnk
## AEE788 (NVP-AEE788)                                    egfr, flt, vegfr, her2
## WZ3146                                                                   egfr
## SGI-1776 free base                                                        pim
## CHIR-99021 (CT99021)                                                    gsk-3
## PIK-93                                                            pi3k, vegfr
## LY2090314                                                               gsk-3
## AZD2858                                                                 gsk-3
## CHIR-98014                                                              gsk-3
## AZD1080                                                                 gsk-3
## CHIR-99021 (CT99021) HCl                                        pi3k/akt/mtor
## 1-Azakenpaullone                                                        gsk-3
## Enzastaurin (LY317615)                                                    pkc
## Dabrafenib (GSK2118436)                                                   raf
## MLN2480                                                                   raf
## Piceatannol                                                               syk
## NVP-BHG712                                           vegfr, src, raf, bcr-abl
## YM201636                                                                 pi3k
## Sotrastaurin                                                              pkc
## AC480 (BMS-599626)                                                       her2
## AZ 628                                                                    raf
## LDN-214117                                                      tgf-beta/smad
## PP1                                                                       src
## PP2                                                                       src
## Mubritinib (TAK 165)                                                     her2
## VPS34-IN1                                                                pi3k
## FH535                                                        wnt/beta-catenin
## Tyrphostin 9                                                             egfr
## LGK-974                                                      wnt/beta-catenin
## PQ 401                                                                 igf-1r
## Tyrphostin AG 879                                                        her2
## YO-01027                                                      gamma-secretase
## XMD8-92                                                                   erk
## GF109203X                                                                 pkc
## Go 6983                                                                   pkc
## LY2835219                                                                 cdk
## ERK5-IN-1                                                                 erk
## CP-673451                                                               pdgfr
## Crenolanib (CP-868596)                                                  pdgfr
## PF-543                                                                  sphk1
## LDC000067                                                                 cdk
## PHA-793887                                                                cdk
## AZD9291                                                                  egfr
## GZD824                                                                bcr-abl
## JNK-IN-8                                                                  jnk
## Fostamatinib (R788)                                                       syk
## TAK-901                                                         aurora kinase
## SU6656                                                                    src
## LY2784544                                                                 jak
## SU9516                                                                    cdk
## LY2603618                                                                 chk
## PF-477736                                                                 chk
## MK-5108 (VX-689)                                                aurora kinase
## HTH-01-015                                                               ampk
## MK-8745                                                         aurora kinase
## TAK-632                                                                   raf
## GSK1838705A                                                        igf-1, alk
## BMS-345541                                                            i_b/ikk
## Dovitinib (TKI-258) Dilactic Acid              flt, fgfr, pdgfr, vegfr, c-kit
## Pazopanib                                                               vegfr
## Sorafenib                                                                 raf
## PRI-724                                                      wnt/beta-catenin
## Nintedanib (BIBF 1120)_uncertain                           vegfr, pdgfr, fgfr
## WIKI4                                                        wnt/beta-catenin
## BIO                                                                     gsk-3
## Semaxanib (SU5416)                                                      vegfr
## DCC-2036 (Rebastinib)                                                 bcr-abl
## Purvalanol A                                                              cdk
## CEP-33779                                                                 jak
## ASP3026                                                                   alk
## WZ4003                                                                   ampk
## PD173074                                                          fgfr, vegfr
## NVP-BSK805 2HCl                                                           jak
## AZD4547                                                                  fgfr
## CX-6258 HCl                                                               pim
## Linifanib (ABT-869)                                              pdgfr, vegfr
## SU11274                                                                 c-met
## Sunitinib Malate                                     vegfr, pdgfr, c-kit, flt
## ICG-001                                                      wnt/beta-catenin
## K02288                                                          tgf-beta/smad
## TWS119                                                                  gsk-3
## Aurora A Inhibitor I                                            aurora kinase
## OSU-03012 (AR-12)                                                       pdk-1
## PHA-680632                                                      aurora kinase
## Barasertib (AZD1152-HQPA)                                       aurora kinase
## ZM 447439                                                       aurora kinase
## Dovitinib (TKI-258, CHIR-258)                  c-kit, fgfr, flt, vegfr, pdgfr
## Quizartinib (AC220)                                                       flt
## PHA-665752                                                              c-met
## Axitinib                                                  vegfr, pdgfr, c-kit
## Bosutinib (SKI-606)                                                       src
## PRT062607 (P505-15, BIIB057) HCl                                          syk
## Sorafenib Tosylate                                          vegfr, pdgfr, raf
## WH-4-023                                                                  src
## AG-1024                                                                igf-1r
## Amuvatinib (MP-470)                           c-met, c-kit, pdgfr, flt, c-ret
## Lapatinib (GW-572016) Ditosylate                                   egfr, her2
## Cediranib (AZD2171)                                                vegfr, flt
## U0126-EtOH                                                                mek
## Ponatinib (AP24534)                          bcr-abl, vegfr, fgfr, pdgfr, flt
## DASA-58                                                                  pkm2
## Dasatinib                                                 src, bcr-abl, c-kit
## PF-573228                                                                 fak
## BMS-265246                                                                cdk
## KU-60019                                                                  atm
##                                              EnrichedPathway EnrichedTarget
## Ulixertinib (BVD-523, VRT752271)                        MAPK           <NA>
## TAK-733                                                 MAPK            mek
## Trametinib (GSK1120212)                                 MAPK            mek
## Cobimetinib (GDC-0973, RG7420)                          MAPK            mek
## MEK162 (ARRY-162, ARRY-438162)                          MAPK            mek
## Selumetinib (AZD6244)                                   MAPK            mek
## Refametinib (RDEA119, Bay 86-9766)                      <NA>            mek
## AZD8330                                                 MAPK            mek
## Pimasertib (AS-703026)                                  MAPK            mek
## RAF265 (CHIR-265)                                       MAPK           <NA>
## PD184352 (CI-1040)                                      MAPK            mek
## PD318088                                                MAPK            mek
## PD0325901                                               <NA>            mek
## VX-11e                                                  MAPK           <NA>
## Alisertib (MLN8237)                                     <NA>           <NA>
## GSK2292767                                              <NA>           <NA>
## Hesperadin                                              <NA>           <NA>
## KW-2449                                                 <NA>           <NA>
## PF-4708671                                              <NA>           <NA>
## BMS-754807                                              <NA>           <NA>
## LY3023414                                               <NA>           <NA>
## Crizotinib (PF-02341066)                                <NA>           <NA>
## ENMD-2076                                               <NA>           <NA>
## HMN-214                                                 <NA>           <NA>
## BKM120 (NVP-BKM120, Buparlisib)                         <NA>           <NA>
## NVP-AEW541                                              <NA>           <NA>
## AZ 960                                                  <NA>           <NA>
## GSK2636771                                              <NA>           <NA>
## RepSox                                                  <NA>           <NA>
## Foretinib (GSK1363089)                                  <NA>           <NA>
## Danusertib (PHA-739358)                                 <NA>  aurora kinase
## SNS-314 Mesylate                                        <NA>  aurora kinase
## CYC116                                                  <NA>  aurora kinase
## VX-680 (Tozasertib, MK-0457)                            <NA>  aurora kinase
## AZD1480                                                 <NA>           <NA>
## BX-912                                                  <NA>           <NA>
## PD173955                                                <NA>           <NA>
## TPCA-1                                                  <NA>           <NA>
## AZD7762                                                 <NA>           <NA>
## Rigosertib (ON-01910)                                   <NA>            plk
## BI 2536                                                 <NA>            plk
## Flavopiridol (Alvocidib)                                <NA>           <NA>
## AT7519                                                  <NA>           <NA>
## SNS-032 (BMS-387032)                                    <NA>           <NA>
## CUDC-907                              Cytoskeletal Signaling           <NA>
## Irinotecan / SN-38                                      <NA>           <NA>
## JNJ-7706621                                             <NA>           <NA>
## CHIR-124                                                <NA>           <NA>
## Pacritinib (SB1518)                                     <NA>           <NA>
## CUDC-101                                                <NA>           <NA>
## AT9283                                                  <NA>           <NA>
## GSK461364                                               <NA>            plk
## BGT226 (NVP-BGT226)                                     <NA>           <NA>
## Bortezomib                                              <NA>           <NA>
## Staurosporine_500nM                                     <NA>           <NA>
## IMD 0354                                                <NA>           <NA>
## Triciribine                                             <NA>           <NA>
## FRAX597                               Cytoskeletal Signaling           <NA>
## Golvatinib (E7050)                                      <NA>          c-met
## Tepotinib (EMD 1214063)                                 <NA>          c-met
## IKK-16 (IKK Inhibitor VII)                              <NA>           <NA>
## LDK378                                                  <NA>            alk
## AMG-900                                                 <NA>           <NA>
## KX2-391                                                 <NA>           <NA>
## JNK Inhibitor IX                                        <NA>           <NA>
## Tivantinib (ARQ 197)                                    <NA>          c-met
## VE-822                                         PI3K/Akt/mTOR        atm/atr
## HS-173                                         PI3K/Akt/mTOR           <NA>
## Wnt agonist 1                                           <NA>           <NA>
## AZ20                                           PI3K/Akt/mTOR        atm/atr
## AZD6738                                        PI3K/Akt/mTOR        atm/atr
## Ro 31-8220 Mesylate                                     <NA>           <NA>
## Ro3280                                                  <NA>           <NA>
## PF-3758309                            Cytoskeletal Signaling           <NA>
## PF-00562271                                             <NA>            fak
## PF-562271                                               <NA>            fak
## R547                                              Cell Cycle            cdk
## Flavopiridol HCl                                  Cell Cycle            cdk
## PHA-767491                                        Cell Cycle            cdk
## AZD5438                                           Cell Cycle            cdk
## A-674563                                                <NA>            cdk
## Dinaciclib (SCH727965)                            Cell Cycle            cdk
## P276-00                                           Cell Cycle            cdk
## AP26113                                                 <NA>            alk
## SC1                                                     <NA>           <NA>
## AZD3463                                                 <NA>            alk
## GSK2126458 (GSK458)                                     <NA>           <NA>
## Torin 2                                                 <NA>           <NA>
## SGI-7079                                                <NA>           <NA>
## PF-431396                                               <NA>            fak
## TAE226 (NVP-TAE226)                                     <NA>            fak
## Milciclib (PHA-848125)                                  <NA>           <NA>
## TG101209                                                <NA>           <NA>
## TG101348 (SAR302503)                                    <NA>           <NA>
## CO-1686 (AVL-301)                                       <NA>           <NA>
## Entrectinib (RXDX-101)                                  <NA>           <NA>
## A66                                            PI3K/Akt/mTOR           <NA>
## BYL719                                         PI3K/Akt/mTOR           <NA>
## AVL-292                                                 <NA>           <NA>
## Akti-1/2                                       PI3K/Akt/mTOR            akt
## WAY-600                                        PI3K/Akt/mTOR           mtor
## AZD8055                                        PI3K/Akt/mTOR           mtor
## CH5132799                                      PI3K/Akt/mTOR           mtor
## WYE-125132 (WYE-132)                           PI3K/Akt/mTOR           mtor
## PF-04691502                                    PI3K/Akt/mTOR           mtor
## PP121                                                   <NA>           mtor
## GDC-0980 (RG7422)                              PI3K/Akt/mTOR           mtor
## INK 128 (MLN0128)                              PI3K/Akt/mTOR           mtor
## VS-5584 (SB2343)                               PI3K/Akt/mTOR           pi3k
## CCT128930                                      PI3K/Akt/mTOR            akt
## GDC-0068                                       PI3K/Akt/mTOR            akt
## ETP-46464                                      PI3K/Akt/mTOR           mtor
## AZD2014                                        PI3K/Akt/mTOR           mtor
## GDC-0349                                       PI3K/Akt/mTOR           mtor
## GSK2334470                                     PI3K/Akt/mTOR           <NA>
## OSI-027                                        PI3K/Akt/mTOR           mtor
## BMS-536924                                              <NA>           <NA>
## MK-2206 2HCl                                            <NA>            akt
## OSI-906 (Linsitinib)                                    <NA>           <NA>
## ZSTK474                                                 <NA>           <NA>
## KU-0063794                                     PI3K/Akt/mTOR           mtor
## WYE-354                                        PI3K/Akt/mTOR           mtor
## CC-223                                         PI3K/Akt/mTOR           mtor
## PP242                                          PI3K/Akt/mTOR           mtor
## GSK690693                                               <NA>            akt
## AZD5363                                        PI3K/Akt/mTOR            akt
## Uprosertib (GSK2141795)                        PI3K/Akt/mTOR            akt
## AT13148                                        PI3K/Akt/mTOR            akt
## AT7867                                         PI3K/Akt/mTOR            akt
## Temsirolimus (CCI-779, NSC 683864)                      <NA>           mtor
## Everolimus (RAD001)                                     <NA>           mtor
## Ridaforolimus (Deforolimus, MK-8669)           PI3K/Akt/mTOR           mtor
## Ibrutinib (PCI-32765)                                   <NA>            src
## ONO-4059                                                <NA>           <NA>
## AG-1478 (Tyrphostin AG-1478)         Protein Tyrosine Kinase           egfr
## ZM 306416                            Protein Tyrosine Kinase           <NA>
## CNX-2006                             Protein Tyrosine Kinase           egfr
## PD168393                             Protein Tyrosine Kinase           egfr
## AZD3759                              Protein Tyrosine Kinase           egfr
## Dacomitinib (PF299804, PF299)        Protein Tyrosine Kinase           egfr
## Saracatinib (AZD0530)                                   <NA>            src
## Gefitinib (ZD1839)                   Protein Tyrosine Kinase           egfr
## OSI-420                              Protein Tyrosine Kinase           egfr
## AZD8931 (Sapitinib)                  Protein Tyrosine Kinase           egfr
## Pelitinib (EKB-569)                  Protein Tyrosine Kinase           egfr
## AST-1306                             Protein Tyrosine Kinase           egfr
## Imatinib Mesylate (STI571)           Protein Tyrosine Kinase           <NA>
## Vacquinol-1                                             <NA>           <NA>
## AEE788 (NVP-AEE788)                  Protein Tyrosine Kinase           egfr
## WZ3146                               Protein Tyrosine Kinase           egfr
## SGI-1776 free base                                      <NA>           <NA>
## CHIR-99021 (CT99021)                                    <NA>           <NA>
## PIK-93                                                  <NA>           <NA>
## LY2090314                                      PI3K/Akt/mTOR          gsk-3
## AZD2858                                        PI3K/Akt/mTOR          gsk-3
## CHIR-98014                                     PI3K/Akt/mTOR          gsk-3
## AZD1080                                        PI3K/Akt/mTOR          gsk-3
## CHIR-99021 (CT99021) HCl                       PI3K/Akt/mTOR           <NA>
## 1-Azakenpaullone                                        <NA>          gsk-3
## Enzastaurin (LY317615)                                  <NA>           <NA>
## Dabrafenib (GSK2118436)                                 <NA>            raf
## MLN2480                                                 <NA>            raf
## Piceatannol                                             <NA>           <NA>
## NVP-BHG712                                              <NA>            raf
## YM201636                                                <NA>           <NA>
## Sotrastaurin                                            <NA>           <NA>
## AC480 (BMS-599626)                                      <NA>           her2
## AZ 628                                                  <NA>            raf
## LDN-214117                                              <NA>           <NA>
## PP1                                                     <NA>            src
## PP2                                                     <NA>            src
## Mubritinib (TAK 165)                                    <NA>           her2
## VPS34-IN1                                               <NA>           <NA>
## FH535                                                   <NA>           <NA>
## Tyrphostin 9                                            <NA>           <NA>
## LGK-974                                                 <NA>           <NA>
## PQ 401                                                  <NA>           <NA>
## Tyrphostin AG 879                                       <NA>           her2
## YO-01027                                                <NA>           <NA>
## XMD8-92                                                 <NA>           <NA>
## GF109203X                                               <NA>           <NA>
## Go 6983                                                 <NA>           <NA>
## LY2835219                                               <NA>           <NA>
## ERK5-IN-1                                               <NA>           <NA>
## CP-673451                                               <NA>           <NA>
## Crenolanib (CP-868596)                                  <NA>           <NA>
## PF-543                                                  <NA>           <NA>
## LDC000067                                         Cell Cycle           <NA>
## PHA-793887                                        Cell Cycle           <NA>
## AZD9291                                                 <NA>           <NA>
## GZD824                                                  <NA>           <NA>
## JNK-IN-8                                                <NA>           <NA>
## Fostamatinib (R788)                                     <NA>           <NA>
## TAK-901                                           Cell Cycle           <NA>
## SU6656                                                  <NA>           <NA>
## LY2784544                                               <NA>           <NA>
## SU9516                                            Cell Cycle           <NA>
## LY2603618                                         Cell Cycle           <NA>
## PF-477736                                         Cell Cycle           <NA>
## MK-5108 (VX-689)                                  Cell Cycle           <NA>
## HTH-01-015                                              <NA>           <NA>
## MK-8745                                           Cell Cycle           <NA>
## TAK-632                                                 <NA>           <NA>
## GSK1838705A                                             <NA>           <NA>
## BMS-345541                                              <NA>           <NA>
## Dovitinib (TKI-258) Dilactic Acid                       <NA>           <NA>
## Pazopanib                                               <NA>          vegfr
## Sorafenib                                               <NA>           <NA>
## PRI-724                                                 <NA>           <NA>
## Nintedanib (BIBF 1120)_uncertain                        <NA>          vegfr
## WIKI4                                                   <NA>           <NA>
## BIO                                                     <NA>           <NA>
## Semaxanib (SU5416)                                      <NA>          vegfr
## DCC-2036 (Rebastinib)                                   <NA>           <NA>
## Purvalanol A                                            <NA>           <NA>
## CEP-33779                                           JAK/STAT           <NA>
## ASP3026                                                 <NA>           <NA>
## WZ4003                                                  <NA>           <NA>
## PD173074                                                <NA>          vegfr
## NVP-BSK805 2HCl                                     JAK/STAT           <NA>
## AZD4547                                                 <NA>           fgfr
## CX-6258 HCl                                         JAK/STAT           <NA>
## Linifanib (ABT-869)                                     <NA>          pdgfr
## SU11274                                                 <NA>          c-met
## Sunitinib Malate                                        <NA>          pdgfr
## ICG-001                                                 <NA>           <NA>
## K02288                                                  <NA>           <NA>
## TWS119                                                  <NA>           <NA>
## Aurora A Inhibitor I                                    <NA>           <NA>
## OSU-03012 (AR-12)                                       <NA>           <NA>
## PHA-680632                                              <NA>  aurora kinase
## Barasertib (AZD1152-HQPA)                               <NA>  aurora kinase
## ZM 447439                                               <NA>  aurora kinase
## Dovitinib (TKI-258, CHIR-258)                   Angiogenesis          pdgfr
## Quizartinib (AC220)                             Angiogenesis            flt
## PHA-665752                                              <NA>          c-met
## Axitinib                                                <NA>          pdgfr
## Bosutinib (SKI-606)                             Angiogenesis           <NA>
## PRT062607 (P505-15, BIIB057) HCl                Angiogenesis           <NA>
## Sorafenib Tosylate                                      <NA>          pdgfr
## WH-4-023                                        Angiogenesis           <NA>
## AG-1024                                                 <NA>           <NA>
## Amuvatinib (MP-470)                                     <NA>          pdgfr
## Lapatinib (GW-572016) Ditosylate                        <NA>           <NA>
## Cediranib (AZD2171)                                     <NA>          vegfr
## U0126-EtOH                                              <NA>           <NA>
## Ponatinib (AP24534)                             Angiogenesis          pdgfr
## DASA-58                                                 <NA>           <NA>
## Dasatinib                                       Angiogenesis          c-kit
## PF-573228                                       Angiogenesis           <NA>
## BMS-265246                                              <NA>           <NA>
## KU-60019                                                <NA>           <NA>
##                                      Lethality
## Ulixertinib (BVD-523, VRT752271)             0
## TAK-733                                      6
## Trametinib (GSK1120212)                      5
## Cobimetinib (GDC-0973, RG7420)               4
## MEK162 (ARRY-162, ARRY-438162)               2
## Selumetinib (AZD6244)                        2
## Refametinib (RDEA119, Bay 86-9766)           4
## AZD8330                                      4
## Pimasertib (AS-703026)                       3
## RAF265 (CHIR-265)                            6
## PD184352 (CI-1040)                           0
## PD318088                                     2
## PD0325901                                    4
## VX-11e                                       1
## Alisertib (MLN8237)                          0
## GSK2292767                                   0
## Hesperadin                                   3
## KW-2449                                      2
## PF-4708671                                   0
## BMS-754807                                   3
## LY3023414                                    2
## Crizotinib (PF-02341066)                     2
## ENMD-2076                                    1
## HMN-214                                      1
## BKM120 (NVP-BKM120, Buparlisib)              2
## NVP-AEW541                                   4
## AZ 960                                       1
## GSK2636771                                   0
## RepSox                                       0
## Foretinib (GSK1363089)                       0
## Danusertib (PHA-739358)                      0
## SNS-314 Mesylate                             0
## CYC116                                       0
## VX-680 (Tozasertib, MK-0457)                 0
## AZD1480                                      1
## BX-912                                       0
## PD173955                                     0
## TPCA-1                                       0
## AZD7762                                      7
## Rigosertib (ON-01910)                        5
## BI 2536                                      3
## Flavopiridol (Alvocidib)                    10
## AT7519                                       8
## SNS-032 (BMS-387032)                         9
## CUDC-907                                    12
## Irinotecan / SN-38                          14
## JNJ-7706621                                  6
## CHIR-124                                     9
## Pacritinib (SB1518)                         14
## CUDC-101                                     5
## AT9283                                      10
## GSK461364                                    0
## BGT226 (NVP-BGT226)                         12
## Bortezomib                                  14
## Staurosporine_500nM                          4
## IMD 0354                                     3
## Triciribine                                  0
## FRAX597                                      0
## Golvatinib (E7050)                           3
## Tepotinib (EMD 1214063)                      2
## IKK-16 (IKK Inhibitor VII)                   4
## LDK378                                       4
## AMG-900                                      0
## KX2-391                                      1
## JNK Inhibitor IX                             0
## Tivantinib (ARQ 197)                         1
## VE-822                                       2
## HS-173                                       0
## Wnt agonist 1                                0
## AZ20                                         1
## AZD6738                                      2
## Ro 31-8220 Mesylate                          2
## Ro3280                                       0
## PF-3758309                                   5
## PF-00562271                                  5
## PF-562271                                    4
## R547                                        10
## Flavopiridol HCl                             8
## PHA-767491                                   5
## AZD5438                                      9
## A-674563                                    11
## Dinaciclib (SCH727965)                       9
## P276-00                                     10
## AP26113                                      8
## SC1                                          5
## AZD3463                                      6
## GSK2126458 (GSK458)                          4
## Torin 2                                      6
## SGI-7079                                     3
## PF-431396                                    1
## TAE226 (NVP-TAE226)                          2
## Milciclib (PHA-848125)                       6
## TG101209                                     3
## TG101348 (SAR302503)                         7
## CO-1686 (AVL-301)                            0
## Entrectinib (RXDX-101)                       0
## A66                                          0
## BYL719                                       0
## AVL-292                                      0
## Akti-1/2                                     0
## WAY-600                                      0
## AZD8055                                      0
## CH5132799                                    0
## WYE-125132 (WYE-132)                         0
## PF-04691502                                  0
## PP121                                        7
## GDC-0980 (RG7422)                            0
## INK 128 (MLN0128)                            0
## VS-5584 (SB2343)                             0
## CCT128930                                    0
## GDC-0068                                     0
## ETP-46464                                    0
## AZD2014                                      0
## GDC-0349                                     0
## GSK2334470                                   0
## OSI-027                                      0
## BMS-536924                                   0
## MK-2206 2HCl                                 0
## OSI-906 (Linsitinib)                         0
## ZSTK474                                      0
## KU-0063794                                   0
## WYE-354                                      0
## CC-223                                       0
## PP242                                        0
## GSK690693                                    0
## AZD5363                                      0
## Uprosertib (GSK2141795)                      0
## AT13148                                      0
## AT7867                                       0
## Temsirolimus (CCI-779, NSC 683864)           0
## Everolimus (RAD001)                          0
## Ridaforolimus (Deforolimus, MK-8669)         0
## Ibrutinib (PCI-32765)                        0
## ONO-4059                                     0
## AG-1478 (Tyrphostin AG-1478)                 0
## ZM 306416                                    0
## CNX-2006                                     1
## PD168393                                     0
## AZD3759                                      0
## Dacomitinib (PF299804, PF299)                1
## Saracatinib (AZD0530)                        1
## Gefitinib (ZD1839)                           0
## OSI-420                                      1
## AZD8931 (Sapitinib)                          0
## Pelitinib (EKB-569)                          2
## AST-1306                                     0
## Imatinib Mesylate (STI571)                   0
## Vacquinol-1                                  2
## AEE788 (NVP-AEE788)                          1
## WZ3146                                       0
## SGI-1776 free base                           2
## CHIR-99021 (CT99021)                         0
## PIK-93                                       0
## LY2090314                                    0
## AZD2858                                      0
## CHIR-98014                                   0
## AZD1080                                      0
## CHIR-99021 (CT99021) HCl                     0
## 1-Azakenpaullone                             0
## Enzastaurin (LY317615)                       0
## Dabrafenib (GSK2118436)                      0
## MLN2480                                      0
## Piceatannol                                  0
## NVP-BHG712                                   0
## YM201636                                     0
## Sotrastaurin                                 0
## AC480 (BMS-599626)                           0
## AZ 628                                       0
## LDN-214117                                   0
## PP1                                          0
## PP2                                          0
## Mubritinib (TAK 165)                         0
## VPS34-IN1                                    0
## FH535                                        0
## Tyrphostin 9                                 0
## LGK-974                                      0
## PQ 401                                       0
## Tyrphostin AG 879                            0
## YO-01027                                     0
## XMD8-92                                      0
## GF109203X                                    0
## Go 6983                                      0
## LY2835219                                    0
## ERK5-IN-1                                    0
## CP-673451                                    0
## Crenolanib (CP-868596)                       0
## PF-543                                       0
## LDC000067                                    0
## PHA-793887                                   0
## AZD9291                                      1
## GZD824                                       1
## JNK-IN-8                                     1
## Fostamatinib (R788)                          0
## TAK-901                                      1
## SU6656                                       0
## LY2784544                                    0
## SU9516                                       0
## LY2603618                                    0
## PF-477736                                    1
## MK-5108 (VX-689)                             0
## HTH-01-015                                   0
## MK-8745                                      0
## TAK-632                                      0
## GSK1838705A                                  0
## BMS-345541                                   0
## Dovitinib (TKI-258) Dilactic Acid            0
## Pazopanib                                    0
## Sorafenib                                    0
## PRI-724                                      0
## Nintedanib (BIBF 1120)_uncertain             0
## WIKI4                                        0
## BIO                                          0
## Semaxanib (SU5416)                           0
## DCC-2036 (Rebastinib)                        0
## Purvalanol A                                 0
## CEP-33779                                    0
## ASP3026                                      0
## WZ4003                                       0
## PD173074                                     0
## NVP-BSK805 2HCl                              0
## AZD4547                                      0
## CX-6258 HCl                                  0
## Linifanib (ABT-869)                          0
## SU11274                                      0
## Sunitinib Malate                             0
## ICG-001                                      0
## K02288                                       0
## TWS119                                       0
## Aurora A Inhibitor I                         0
## OSU-03012 (AR-12)                            0
## PHA-680632                                   0
## Barasertib (AZD1152-HQPA)                    0
## ZM 447439                                    0
## Dovitinib (TKI-258, CHIR-258)                0
## Quizartinib (AC220)                          0
## PHA-665752                                   0
## Axitinib                                     0
## Bosutinib (SKI-606)                          1
## PRT062607 (P505-15, BIIB057) HCl             0
## Sorafenib Tosylate                           0
## WH-4-023                                     0
## AG-1024                                      0
## Amuvatinib (MP-470)                          0
## Lapatinib (GW-572016) Ditosylate             0
## Cediranib (AZD2171)                          0
## U0126-EtOH                                   0
## Ponatinib (AP24534)                          1
## DASA-58                                      0
## Dasatinib                                    0
## PF-573228                                    0
## BMS-265246                                   0
## KU-60019                                     0

Generate a force-directed graph from these similarities

# Set up adjacency matrix
adjmatrix = d
adjmatrix[adjmatrix > 45] = 0

# Resort matrix to make sure annotated nodes are above unannotated ones
sort_order = order(annotation$Target, na.last = FALSE)
adjmatrix = adjmatrix[sort_order, sort_order]

# Remove drugs without any connections
sel_indices = colSums(adjmatrix != 0) != 0
adjmatrix = adjmatrix[sel_indices, sel_indices]

# Convert to cosine distance: D = 1 - cos(angle)
# adjmatrix = 1 - cos(adjmatrix * pi / 180)

# Generate network
adjmatrix = Matrix::Matrix(data = adjmatrix, sparse = TRUE)
net = graph_from_adjacency_matrix(
  adjmatrix = adjmatrix, mode = "undirected", diag = FALSE, weighted = TRUE)

# Assign targets and colors
V(net)$target = annotation[match(V(net)$name, rownames(annotation)), "Target"]
V(net)$color = V(net)$target
for(target in na.omit(unique(V(net)$target))) {
  regex = paste0("\\b", target, "\\b")
  V(net)$color = gsub(regex, anno_colorScale$Target[target], V(net)$color)}
V(net)$color[is.na(V(net)$color)] = "white"

# Assign size
V(net)$size = 5
V(net)[!is.na(V(net)$target)]$size = 7.5

# # Create plot
# e = get.edgelist(net, names = FALSE)
# l = qgraph.layout.fruchtermanreingold(
#   edgelist = e, vcount = vcount(net), 
#   area=20*(vcount(net)^2), repulse.rad=(vcount(net)^3.1))
# # l = layout_with_graphopt(graph = net, niter = 1000, mass = 100)
# plot.igraph(net, vertex.label = NA, layout=l, 
#             edge.width = 0.5, edge.color = "lightgray")
# if(save_images) {
#   pdf(file = file.path(img_out_dir, "EffectVectorNetwork_allLines.pdf"), 
#       width = 7, height = 7, useDingbats = FALSE)
#   plot.igraph(net, vertex.label = NA, layout=l, 
#             edge.width = 0.5, edge.color = "lightgray")
#   dev.off()}

Clinical Cancer Panel

sel_indices = !is.na(drug_effect_metadata$Concentration)
profiles = drug_effect_profiles[sel_indices, ]
metadata = drug_effect_metadata[sel_indices, ]
# Sort for convenience
order_indices = order(rownames(profiles))
profiles = profiles[order_indices, ]
metadata = metadata[order_indices, ]

Drugs Active at All Concentrations

sig_concentrations = aggregate(
  x = metadata$AUC_Mean >= auc_thresh, 
  by = list("Drug" = metadata$Drug, 
            "Line" = metadata$Line), 
  FUN = sum)

sig_conc_table = as.data.frame(table(sig_concentrations$x))
sig_conc_table$TextLoc = sig_conc_table$Freq - 50
ggplot(data = sig_conc_table) + 
  geom_col(mapping = aes(x = Var1, y = Freq)) + theme_vignette() + 
  geom_text(mapping = aes(x = Var1, y = TextLoc, label = Freq), 
            color = "white", fontface = "bold", size = 3) + 
  xlab("Active Concentrations") + ylab("Number of Drugs") + coord_flip() + 
  theme(axis.line = element_blank(), axis.text.x = element_blank(), 
        axis.ticks = element_blank())
if(save_images) ggsave(
  filename = file.path(img_out_dir, "Barplot_NumActiveConcentrations.pdf"),
  width = 2.5, height = 3)
  

# The number of concentrations at which drugs should be active
conc_thresh = 5
sig_concentrations = sig_concentrations[
  sig_concentrations$x >= conc_thresh, ]

# Create heatmap for each entry
for(ii in seq_len(nrow(sig_concentrations))) {
  drug = sig_concentrations[ii, "Drug"]
  line = sig_concentrations[ii, "Line"]
  sel_indices = metadata$Line == line & metadata$Drug == drug
  entry = profiles[sel_indices, ]
  entry_md = metadata[sel_indices, ]
  
  angles = get_angles(entry)
  d = acos(angles)*180/pi
  hc = hclust(as.dist(d), method = "ward.D2")
  
  hm_colorscale = colorRampPalette(
    rev(c("#f7f7f7", "#E0F3F8", "#91BFDB", "#4575B4")))(150)
  
  pheatmap(
    d, cluster_rows = hc, cluster_cols = hc, color = hm_colorscale, 
    display_numbers = round(d), cellwidth = 20, cellheight = 20, 
    labels_row = entry_md$Concentration, show_colnames = FALSE, 
    main = paste0(line, " - ", drug))
}